How to "stick" a UIView to a page on a PDFViewCtrl on iOS

I’m implementing a functionality on the reader so I can add on the top of the PDFReader for example a UIButton that has a background image.
The idea is to add that UIButton at a certain point on one specific page and when the user zooms in, zooms out or scrolls through that page the UIButton resizes and moves with the pages so it appears always on the top of the same point in the pdf.

What I’m doing right now is to add to the PDFViewCtrl’s public ivar ContainerView the UIButton like this.

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, width, height)];
[m_pdfViewCtrl->ContainerView addSubview:button];

The problem I’m facing is that when I zoom in, zoom out or scroll through the page, the UIButton is all the time in the same place on the screen and doesn’t resize at the same time with the pdf page.
What I was doing to solve that problem was to implement in the following delegate method this code to resize the frame of the UIButton manually but I’m having trouble to resize it to the correct place because it doesn’t work as I expect.

  • (void)onLayoutChanged {

// Get the subviews of the view
NSArray *subviews = [m_pdfViewCtrl->ContainerView subviews];

for (UIView *subView in subviews) {

if ([subView isKindOfClass:[UIButton class]]) {
[subView setFrame:CGRectMake(x * fltZoom, y * fltZoom, width * fltZoom, height * fltZoom)];


I would like to know first, if I’m using the correct approach in order to achieve what I’m trying to do, and in that case, how can I resize the UIButton properly so it is always resizing and scrolling with the page.
However what you will need to implement is logic for when the user releases their fingers after a zoom. When this occurs the ContainerView will change size to reflect the new total scrollable area of the document. If the item that is a subview of ContainerView is supposed to be stationary relative to a page (which is likely to be the case), the PDFViewCtrl methods ConvScreenPtToPagePt and ConvPagePtToScreenPt will come in useful in calculating the new frame that the button should have when a subview of ContainerView (which is in screen coordinates).

When i implement same thing in swift, i am getting error like (Value of type 'myPDFViewCtrl' has no member 'ContainerView')