You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. //
  2. // PDFViewController.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon James Kim on 2019/12/23.
  6. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. import PDFKit
  10. struct PDFConfiguration {
  11. var title: String
  12. var url: String
  13. var autoScales = true
  14. var displayMode: PDFDisplayMode = .singlePageContinuous
  15. }
  16. class PDFViewController: UIViewController {
  17. @IBOutlet private weak var pdfView: PDFView!
  18. private var configure = PDFConfiguration(
  19. title: "PDF TITLE",
  20. url: ""
  21. )
  22. override func viewDidLoad() {
  23. super.viewDidLoad()
  24. }
  25. override func viewWillAppear(_ animated: Bool) {
  26. super.viewWillAppear(animated)
  27. title = configure.title
  28. setupNormalNavigation()
  29. guard let url = URL(string: configure.url) else { return }
  30. let document = PDFDocument(url: url)
  31. pdfView.document = document
  32. pdfView.autoScales = configure.autoScales
  33. pdfView.displayMode = configure.displayMode
  34. }
  35. func showAsPush(
  36. _ target: UIViewController,
  37. configure: PDFConfiguration
  38. ) {
  39. self.configure = configure
  40. target.navigationController?.pushViewController(self, animated: true)
  41. }
  42. }