Set content inset in PDFView

Viewed 976

I am using the new PDFKit framework (https://developer.apple.com/documentation/pdfkit).

I would like, like in UIScrollView, to change the contentInset of my PDFView. Sadly, PDFView doesn't have a property scrollView or contentInset.

Thanks a lot.

1 Answers

PDFView doesn't have a publicly exposed UIScrollView property, but if you iterate the subviews you should find the that first subview is a PDFScrollView (UIScrollView subclass):

UIView *firstSubview = pdfView.subviews.firstObject;
if ([firstSubview isKindOfClass:[UIScrollView class]]) {
    UIScrollView *pdfScrollView = (UIScrollView *)firstSubview;
    pdfScrollView.contentInset = UIEdgeInsetsMake(0, 20.0f, 0, 20.0f);
}

Otherwise the only other option I can think of is to inset the view itself:

pdfView.frame = CGRectInset(pdfView.frame, 10.0f, 10.0f);
Related