Customizing the Toolbar

PSPDFKit by default works with UINavigationController to show the UINavigationBar as the toolbar. You can use regular UIBarButtonItem objects to populate the navigation bar or (bottom) view controller toolbar.

Since PSPDFKit uses custom toolbar logic (for example, when the thumbnails are displayed, we hide the annotation bar button item), PSPDFViewController has a custom navigationItem that you can use to configure the bar button items for different view modes. If you use the leftBarButtonItems and rightBarButtonItems API from UINavigationItem you will set the items for all view modes. Most likely that is not what you want. Instead use setLeftBarButtonItems:forViewMode:animated: or the equivalent for the right side and specify the view mode you want to alter by that call.

If the view mode you change is the one that is currently visible, the navigation bar will update to represent these changes.

PSPDFKit provides several custom bar button items for the most common features:

Property Description
closeButtonItem Closes the PSPDFViewController if pushed modally. Default in leftBarButtonItems.
outlineButtonItem Presents the PSPDFOutlineViewController if there is an outline defined in the PDF. Default entry in rightBarButtonItems. Also available as activity via PSPDFActivityTypeOutline.
searchButtonItem Shows the PSPDFSearchViewController or the PSPDFInlineSearchManager for searching text in the current document. See PSPDFSearchMode in PSPDFConfiguration to configure this. Default entry in rightBarButtonItems.
thumbnailsButtonItem Toggles between the document and the thumbnail view state. (See PSPDFViewMode and setViewMode:animated: Default entry in rightBarButtonItems.
documentEditorButtonItem Toggles between the document and the document editor view state.
printButtonItem Presents the UIPrintInteractionController for document printing. Only displayed if document is allowed to be printed (see allowsPrinting in PSPDFDocument) You should use the activityButtonItem instead. (PSPDFActivityTypeOpenIn)
openInButtonItem Presents the UIDocumentInteractionController controller to open documents in other apps. You should use the activityButtonItem instead.
emailButtonItem Presents the MFMailComposeViewController to send the document via email. Will only work when sending emails is configured on the device. You should use the activityButtonItem instead. (UIActivityTypeMail)
messageButtonItem Presents the MFMessageComposeViewController to send the document via SMS/iMessage. Will only work if iMessage or SMS is configured on the device. You should use the activityButtonItem instead. (UIActivityTypeMessage)
annotationButtonItem Shows and hides the PSPDFAnnotationToolbar toolbar for creating annotations. Requires the PSPDFFeatureMaskAnnotationEditing feature flag.
bookmarkButtonItem Presents the PSPDFBookmarkViewController for creating/editing/viewing bookmarks.
brightnessButtonItem Presents the PSPDFBrightnessViewController to control screen brightness. iOS has a similar feature in the control center, but PSPDFKit brightness includes an additional software brightener.
activityButtonItem Presents the UIActivityViewController for various actions, including many of the above button items. You can configure what activities are included and excluded by setting applicationActivities and excludedActivityTypes in PSPDFConfiguration.

Customizing Button Appearance

Instead of trying to customize existing bar button items or changing the image, the better way is to create your own bar button item and connect both target and action from the predefined buttons that we offer to get the same tap behavior, yet complete customizability in terms of appearance.

If you want to call your own code before our stock code is invoked, you can set the target/action to your method and then call the stock method of the bar button item. Note that the spec allows for an optional sender parameter on target/action pairs, so to be absolutely correct you should use a helper like the psc_targetActionBlock that we ship in PSPDFCatalog. Our internal methods to define a sender parameter, but this is a detail your code should not rely on.

Button visibility

When document is nil or document.isValid returns NO, most buttons will be disabled and not displayed by default. If you need a button to be always visible, add your bar buttons to the barButtonItemsAlwaysEnabled array. By default, this contains the closeButtonItem.

Changing any of these bar button related properties will trigger a reload of the gallery.

Hide the close button

The close button, to dismiss PSPDFViewController when pushed modally, is added automatically to leftBarButtonItems. If you choose to manage the close behavior yourself, or just want to hide the close button, you can set closeBarButtonItem on the PSPDFViewController’s navigationItem to nil.

Hide the toolbar completely

The navigation toolbar used in the standard configuration of PSPDFKit can be removed via the setNavigationBarHidden:animated: call from the standard UINavigationController that displays the PSPDFViewController. Since the PSPDFViewController also has logic to show/hide the HUD, you need to configure to set the userInterfaceViewMode in PSPDFConfiguration to PSPDFUserInterfaceViewModeAlways.

Alternatively, you can subclass the PSPDFViewController to make sure that the navigation bar is always hidden:

override func viewWillLayoutSubviews() {

    self.navigationController?.setNavigationBarHidden(true, animated: false)