iOS-PDF-Reader:简单易用的轻量级 PDF 阅读器组件

iOS-PDF-Reader

PDF Reader for iOS written in Swift

  • Fast and lightweight
  • Thumbnail bar on the bottom to navigate to a specific page
  • Print button on the top right

iOS-PDF-Reader:简单易用的轻量级 PDF 阅读器组件

iOS-PDF-Reader:简单易用的轻量级 PDF 阅读器组件

Requirements

  • iOS 8.0+

Installation

CocoaPods

To install it, simply add the following line to your Podfile :

pod 'PDFReader'

You will also need to make sure you’re opting into using frameworks:

use_frameworks!

Then run pod install with CocoaPods 1.0 or newer.

Carthage

To install it, simply add the following line to your Cartfile :

github "Alua-Kinzhebayeva/iOS-PDF-Reader"

Run carthage update to build the framework and drag the built PDFReader.framework into your Xcode project.

Usage

let documentURL = Bundle.main.url(forResource: "Cupcakes", withExtension: "pdf")!
let document = PDFDocument(fileURL: documentURL)!

let readerController = PDFViewController.createNew(with: document)
navigationController?.pushViewController(readerController, animated: true)

Customizations

Controller Title

PDFViewController.createNew(with: document, title: "Favorite Cupcakes")

Background Color

controller.backgroundColor = .white

Action Button Image and Action

Available Action Styles

/// Action button style
public enum ActionStyle {
    /// Brings up a print modal allowing user to print current PDF
    case print

    /// Brings up an activity sheet to share or open PDF in another app
    case activitySheet

    /// Performs a custom action
    case customAction((Void) -> ())
}
let actionButtonImage = UIImage(named: "cupcakeActionButtonImage")
PDFViewController.createNew(with: document, title: "Favorite Cupcakes", actionButtonImage: actionButtonImage, actionStyle: .activitySheet)

Override the default backbutton

/// Create a button to override the default behavior of the backbutton.  In the below example we create a cancel button which will call our myCancelFunc method on tap.
let myBackButton = UIBarButtonItem(title: "Cancel", style: .done, target: self, action:  #selector(self.myCancelFunc(_:)))
/// Provide your button to createNew using the backButton parameter.  The PDFViewController will then use your button instead of the default backbutton.
PDFViewController.createNew(with: document, title: "Favorite Cupcakes", backButton: myBackButton)

Acknowledgements

Inspired by PDF Reader https://github.com/vfr/Reader and Apple’s example on TiledScrollView

原文 

https://github.com/Alua-Kinzhebayeva/iOS-PDF-Reader

本站部分文章源于互联网,本着传播知识、有益学习和研究的目的进行的转载,为网友免费提供。如有著作权人或出版方提出异议,本站将立即删除。如果您对文章转载有任何疑问请告之我们,以便我们及时纠正。

PS:推荐一个微信公众号: askHarries 或者qq群:474807195,里面会分享一些资深架构师录制的视频录像:有Spring,MyBatis,Netty源码分析,高并发、高性能、分布式、微服务架构的原理,JVM性能优化这些成为架构师必备的知识体系。还能领取免费的学习资源,目前受益良多

转载请注明原文出处:Harries Blog™ » iOS-PDF-Reader:简单易用的轻量级 PDF 阅读器组件

赞 (0)
分享到:更多 ()

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址