Customizing the Frame of Annotation Toolbar

In your PSPDFViewController subclass, override flexibleToolbarContainerContentRect(_:for:) and return a customized rect. Ask super for the default rect if you want to customize it for only one position or to just slightly modify it.

Copy
1
2
3
4
5
6
7
override func flexibleToolbarContainerContentRect(_ container: PSPDFFlexibleToolbarContainer, for position: PSPDFFlexibleToolbarPosition) -> CGRect {
    var rect = super.flexibleToolbarContainerContentRect(container, for: position)
    if position == .positionLeft {
        rect.origin.x += 50
    }
    return rect
}
Copy
1
2
3
4
5
6
7
- (CGRect)flexibleToolbarContainerContentRect:(nonnull PSPDFFlexibleToolbarContainer *)container forToolbarPosition:(PSPDFFlexibleToolbarPosition)position {
    CGRect rect = [super flexibleToolbarContainerContentRect:container forToolbarPosition:position];
    if (position == PSPDFFlexibleToolbarPositionLeft) {
        rect.origin.x += 50;
    }
    return rect;
}

For more details about various ways you can cutomize the look of annotation toolbar, check out our guides on customizing the annotation toolbar and appearance styling.