SimplePDFViewer 0.1.2

SimplePDFViewer 0.1.2

Frank Jia 维护。



  • 作者:
  • Frank Jia

SimplePDFViewer

一个易于使用的 UIViewController,用于渲染本地和远程 PDF,并提供基本的定制和功能。

Version License Platform

简介

SimplePDFViewer 允许在不需要太多定制/高级功能的情况下显示 PDF 文档。该库建立在苹果的 PDFKit 之上。

Standard VC Error VC Dialog

功能包括

  • 从本地/远程 URL、原始数据或 PDFDocument 初始化
  • 跳转到页面对话框
  • 页面跟踪
  • 使用标准 iOS 分享标签(sheet)导出文件
  • 基本定制(颜色、错误消息、VC 标题等)

该库是为了为另一款应用提供基本的 PDF 功能而创建的。由我(Frank Jia)维护。如果有需求,我愿意增加功能和更多定制。请随时通过 [email protected] 联系我。

使用方法

SimplePDFViewer 可通过 CocoaPods 获得。要安装它,只需在 Podfile 中添加以下行

pod 'SimplePDFViewer'

要使用 SimplePDFViewer,请导入 SimplePDFViewer。然后可以如此实例化一个 VC 的实例

let pdfVC = SimplePDFViewController(urlString: ViewController.TEST_PDF_URL)
pdfVC.viewTitle = "Test View Title" // Custom view title on top bar
pdfVC.tint = .red // Tint applies to all views in the VC
pdfVC.exportPDFName = "TestExportPDF" // File name for sharing, default is "Document"
pdfVC.errorMessage = "Uh oh!" // Custom error message if PDF fails to load
pdfVC.dismissalDelegate = self // Customize what happens when close button is pressed

VC 也提供了从 URL、PDFDocument 或原始数据创建构造函数。然后可以使用以下方法来显示 VC

present(pdfVC, animated: true, completion: nil) // Presents modally
navigationController?.pushViewController(pdfVC, animated: true) // Pushes onto navigation stack

委托

目前有一个委托:SimplePDFViewOnDismissDelegate 这里是一个示例实现

func didDismiss(_ sender: SimplePDFViewController) {
// It is your responsibility to dismiss the VC
sender.dismiss(animated: true, completion: nil)
// Do whatever else you want to do
print("Hello!")
}

示例

要运行示例项目,请克隆仓库,然后从示例目录中运行 pod install

许可证

SimplePDFViewer受MIT许可协议保护。有关更多信息,请参阅LICENSE文件。