roborg
roborg

Reputation: 262

Set content inset in PDFView

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.

Upvotes: 3

Views: 1473

Answers (1)

R4N
R4N

Reputation: 2595

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);

Upvotes: 4

Related Questions