Make a eBook Reader with PDFKit in Swift

David Wu
3 min readNov 9, 2018

PDFKit is introduced since iOS 11, and there are three great features in PDFKit that I’d like to introduce by making a horizontal flipping eBook reader. The three features are: Paging, Outline, and Thumbnails.

Paging, Outline, and Thumbnails

Create PDFViewController with Initializer Injection

Once the URL property was injected into PDFViewController, it’s going to be immutable. This is why I choose Initializer Injection over Property Injection and Method Injection.

The only property injected is pdfUrl , and the other properties, document and outline, which is accessible in the local class scope, can be set up during init().

Contents presented in pdfView is determined by document property. Since it never changes, I’ll also assign it doing init().

Set up horizontal paging

Now we have content which was defined in pdfView.document . To make it horizontally scroll like a book, add some settings to PDFView.

--

--