PDFView class


概述

該類可能是你在app中添加PDF功能時僅需處理的類,他可以讓你顯示PDF數(shù)據(jù),允許用戶選擇內(nèi)容,在文檔中跳轉(zhuǎn),設(shè)置縮放級別,負(fù)責(zé)文本內(nèi)容.他也會保存頁面歷史記錄.

你可以通過繼承PDFView來創(chuàng)建一個自定義的PDF界面.

或者用PDFKit的其他工具類,而根本不需要用PDFView.


話題


連接文檔和界面

var document: PDFDocument?

返回一個與PDFView關(guān)聯(lián)的文檔.


在文檔中導(dǎo)航

func canGoBack()

是否能訪問歷史頁中的前一頁.

func canGoForward()?

是否能訪問歷史頁中的下一頁.

func canGoToFirstPage()

是否能訪問文檔中首頁.

func canGoToLastPage()

是否能訪問文檔中的最后頁.

func canGoToNextPage()

是否能訪問文檔中的后一頁.

func canGoToPreviousPage()

是否能訪問文檔中的前一頁.

var currentPage: PDFPage?

當(dāng)前頁

var currentDestination: PDFDestination?

返回當(dāng)前頁中的當(dāng)前點(diǎn)

func goBack(Any?)

在歷史頁中,向后跳轉(zhuǎn)

func goForward(Any?)

在歷史頁中,向前跳轉(zhuǎn)

func goToFirstPage(Any?)

跳轉(zhuǎn)到文檔首頁

func goToLastPage(Any?)

跳轉(zhuǎn)到文檔最后頁

func goToNextPage(Any?)

顯示文檔上一頁

func goToPreviousPage(Any?)

顯示文檔下一頁.

func go(to: PDFPage)

滾到指定頁.

func go(to: PDFDestination)

到指定位置.

func go(to: PDFSelection)

滾到選中區(qū)域的第一個字符.

func go(to: CGRect,on: PDFPage)

滾到頁中的特定區(qū)域.


顯示模型和特征

var displayMode: PDFDisplayMode

返回當(dāng)前的顯示模式.

var displaysPageBreaks: Bool

是否分頁顯示.

var displayBox: PDFDisplayBox

當(dāng)前顯示盒的類型.

var displaysAsBook: Bool

第一頁是否顯示成書的封面.

var backgroundColor: UIColor

背景色.


設(shè)置委托

var delegate: PDFViewDelegate??

protocol PDFViewDelegate


縮放界面

var scaleFactor: CGFloat

當(dāng)前頁面的縮放級別

func zoomIn(Any?)

func canZoomIn()

func zoomOut(Any?)

func canZoomOut()

var autoScales: Bool

是否設(shè)置了自動縮放


鼠標(biāo)位置和事件

func areaOfInterest(forMouse: UIEvent)

返回鼠標(biāo)經(jīng)過區(qū)域的類型

func setCursorFor(PDFAreaOfInterest)

根據(jù)鼠標(biāo)經(jīng)過區(qū)域的類型設(shè)定鼠標(biāo)類型.

func perform(PDFAction)

執(zhí)行指定的動作


選擇處理

var currentSelection: PDFSelection?

func selectAll(Any?)

func clearSelection()

func copy(Any?)

func scrollSelectionToVisible(Any?)

func setCurrentSelection(PDFSelection?,animate: Bool)

var highlightedSelections: [PDFSelection]?



打印

func print(with: NSPrintInfo,autoRotate: Bool)

func print(with: NSPrintInfo,autoRotate: Bool,pageScaling: PDFPrintScalingMode)


view空間和PDFPage空間之間的轉(zhuǎn)換方法

func page(for: CGPoint,nearest: Bool)

func convert(CGPoint,to: PDFPage)

func convert(CGRect,to: PDFPage)

func convert(CGPoint,from: PDFPage)

func convert(CGRect,from: PDFPage)


其它方法

var documentView: UIView?

func rowSize(for: PDFPage)

func layoutDocumentView()

func visiblePages()

func annotationsChanged(on: PDFPage)


常量

enum PDFDisplayMode

struct PDFAreaOfInterest

enum PDFInterpolationQuality


通知

static let PDFViewChangedHistory: NSNotification.Name

static let PDFViewDocumentChanged: NSNotification.Name

static let PDFViewPageChanged: NSNotification.Name

static let PDFViewScaleChanged: NSNotification.Name

static let PDFViewAnnotationHit: NSNotification.Name

static let PDFViewCopyPermission: NSNotification.Name

static let PDFViewPrintPermission: NSNotification.Name

static let PDFViewAnnotationWillHit: NSNotification.Name

用戶點(diǎn)擊了注釋

static let PDFViewSelectionChanged: NSNotification.Name

選中區(qū)域發(fā)生了改變

static let PDFViewDisplayModeChanged: NSNotification.Name

static let PDFViewDisplayBoxChanged: NSNotification.Name

static let PDFViewVisiblePagesChanged: NSNotification.Name

static let PDFViewVisiblePagesChanged: NSNotification.Name


實例屬性

var acceptsDraggedFiles: Bool

var displayDirection: PDFDisplayDirection

var displaysRTL: Bool

var enableDataDetectors: Bool

var interpolationQuality: PDFInterpolationQuality

var isUsingPageViewController: Bool

var maxScaleFactor: CGFloat

var minScaleFactor: CGFloat

var pageBreakMargins: UIEdgeInsets

var scaleFactorForSizeToFit: CGFloat


實例方法

func areaOfInterest(for: CGPoint)

func draw(PDFPage,to: CGContext)

func drawPagePost(PDFPage,to: CGContext)

func usePageViewController(Bool,withViewOptions: [AnyHashable : Any]? = nil)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • SwiftDay011.MySwiftimport UIKitprintln("Hello Swift!")var...
    smile麗語閱讀 4,105評論 0 6
  • 1、隨機(jī)數(shù) 不需要隨機(jī)數(shù)種子 arc4random()%N + begin:產(chǎn)生begin~begin+N的隨機(jī)數(shù)...
    我是小胡胡123閱讀 4,408評論 0 2
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,639評論 19 139
  • 132.轉(zhuǎn)換錯誤成可選值 通過轉(zhuǎn)換錯誤成一個可選值,你可以使用 try? 來處理錯誤。當(dāng)執(zhí)行try?表達(dá)式時,如果...
    無灃閱讀 1,435評論 0 3
  • 1、范型范型所解決的問題 函數(shù)、方法、類型:類,結(jié)構(gòu)體,枚舉,元組類型,協(xié)議參數(shù),返回值,成員函數(shù)參數(shù),成員屬性類...
    我是小胡胡123閱讀 943評論 0 1

友情鏈接更多精彩內(nèi)容