UKPDFReader
UKPDFReader 是一个简单的用于在 iOS 上读取 PDF 的框架
示例
要运行示例项目,请克隆仓库,并首先从示例目录运行 pod install
要求
- iOS 11.0+
- Swift 4
安装
UKPDFReader 通过 CocoaPods 提供。
要安装它,只需将以下行添加到您的 Podfile 中
pod 'UKPDFReader'
use_frameworks!
然后使用 CocoaPods 1.0 或更新的版本运行 pod install
使用方法
导入框架
import UKPDFReader
一旦在NSBundle中接收到pdf文件,获取bundle路径
guard let path = Bundle.main.url(forResource: "swift", withExtension: "pdf") else {
print("failed to unwrap fileURL")
return
}
通过提供“pdf文件路径”来创建UKPDFViewController实例,并将其self作为代理传递
let pdfViewController = UKPDFViewController(pdfUrl: path, delegate: self)
通过提供一些值来自定义PDFReader。所有值都是可选的
pdfViewController.pdfDisplayDirection = .horizontal
pdfViewController.showContentsButton = true
pdfViewController.pdfTitle = "UKPdfReader"
pdfViewController.customizeNavBar(titleTextcolor: .red, titleFont: UIFont.boldSystemFont(ofSize: 24.0), buttonTextcolor: .blue, buttonFont: UIFont.boldSystemFont(ofSize: 18.0))
然后,呈现UKPDFViewController
let navController = UINavigationController.init(rootViewController: pdfViewController)
present(navController, animated: true, completion: nil)
许可
UKPDFReader根据MIT许可证提供。有关更多信息,请参阅LICENSE文件。