Created
December 2, 2019 08:59
-
-
Save amixpal/88e8872f765be9a64969e96b36abe85b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// PdfViewController.swift | |
// Fitme | |
// | |
// Created by paly on 9/9/19. | |
// Copyright © 2019 Paly. All rights reserved. | |
// | |
import UIKit | |
import PDFKit | |
class PdfViewController: UIViewController { | |
@IBOutlet var pdfView: PDFView! | |
var pdfUrl: String! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
initUI() | |
} | |
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
self.navigationController?.setNavigationBarHidden(false , animated: false) | |
let button = UIButton(type: .custom) | |
self.navigationController?.navigationBar.barTintColor = UIColor.white | |
button.setImage(UIImage(named: "ic_back_new"), for: .normal) | |
button.addTarget(self, action: #selector(backButton(_:)), for: .touchUpInside) | |
button.frame = CGRect.init(x: 0, y: 0, width: 30, height: 30) | |
let barButton = UIBarButtonItem(customView: button) | |
self.navigationItem.leftBarButtonItem = barButton | |
self.navigationItem.title = "Detail" | |
UINavigationBar.appearance().titleTextAttributes = [.foregroundColor : UIColor.darkGray] | |
self.navigationController?.navigationBar.clipsToBounds = false | |
self.navigationController?.navigationBar.shadowImage = UIColor(red: 215/255, green: 215/255, blue: 215/255, alpha: 1.0).image(CGSize(width: self.view.frame.width, height: 1)) | |
} | |
@objc private func backButton(_ sender: UIBarButtonItem) { | |
self.navigationController?.popViewController(animated: true) | |
self.dismiss(animated: true, completion: nil) | |
} | |
func initUI(){ | |
let url = URL(string: self.pdfUrl) | |
if let document = PDFDocument(url: url!) { | |
pdfView.autoScales = true | |
pdfView.displayMode = .singlePageContinuous | |
pdfView.displayDirection = .vertical | |
pdfView.document = document | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment