For the complete documentation index, see llms.txt. This page is also available as Markdown.

Customize the Document Viewer UI

The following snippets assume you are using a PTDocumentController called documentController:

PTDocumentController *documentController = [[PTDocumentController alloc] init];
let documentController = PTDocumentController()

Hide the Toolbar Switcher

documentController.toolGroupIndicatorView.hidden = YES;
documentController.toolGroupIndicatorView.isHidden = true

Hide (and show) the annotation toolbar

The toolbar can be programmatically hidden by setting the mode to view group, which is a special group and the only group where the toolbar is hidden:

documentController.toolGroupManager.selectedGroup = documentController.toolGroupManager.viewItemGroup;
documentController.toolGroupManager.selectedGroup = documentController.toolGroupManager.viewItemGroup

The toolbar can be shown again by changing the group to any group other than view:

documentController.toolGroupManager.selectedGroup = documentController.toolGroupManager.drawItemGroup;
documentController.toolGroupManager.selectedGroup = documentController.toolGroupManager.drawItemGroup

Remove toolbars from the switcher

Toolbars can be removed by removing them from the toolGroupManager's groups array. The following code removes the "Draw" and "Pens" toolbars:

NSMutableArray<PTToolItemGroup*>* mutableGroups = [documentController.toolGroupManager.groups mutableCopy];
    
[mutableGroups removeObjectsInArray:@[documentController.toolGroupManager.drawItemGroup, documentController.toolGroupManager.pensItemGroup]];
    
documentController.toolGroupManager.groups = [mutableGroups copy];
var mutableGroups = documentController.toolGroupManager.groups

let groupsToRemove = [documentController.toolGroupManager.drawItemGroup, documentController.toolGroupManager.pensItemGroup]

mutableGroups.removeAll(where: {groupsToRemove.contains($0)})

documentController.toolGroupManager.groups = mutableGroups

Remove buttons from a toolbar

The example below shows how to remove the text highlight and text underline button from a toolbar.

Disabling a tool type entirely

If you want to disable a tool entirely, from all toolbars and the long press menu, please use the annotations permissions system.

Add a tool button to a toolbar

Create a new toolbar

The code below creates a new toolbar that contains a free hand, cloudy and image stamp tool.

Add a button with fully custom behavior

Your app may need a button that does not invoke one of the built in annotation tools. The following code will add a button that calls a selector.

If you want to toggle the items selection, flip its selected property:

Modify UINavigationBar Items

You can modify the navigation bar items. Here is an example of adding a new button (for the current size class):

Tools can also be added:

Note that in the example above, de-selecting the tool button item needs to be implemented by the app, by listening to the Tool Did Change notification.

Add and Remove Toolbar Items (iPhone UI)

These are the buttons that appear at the bottom of the screen.

Last updated

Was this helpful?