Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get UIPageViewController to not clipToBounds

I need to overlay a UIView over a UIPageViewController and was hoping it would let me turn off the clipsToBounds and then resize the interactive bounds area to a smaller height and place another view on top of the non-interactive/non-clipped region.

Unfortunately the UIPageViewController resizes the childViewController in some way where it will clip it no matter what.

What I want is something like this:

How can I achieve this? I can find no samples of doing anything like this and did try to use the UICollectionViewController instead with paging but it doesn't have the smooth gaps between pages like the UIPageViewController does.

like image 336
cynistersix Avatar asked May 13 '15 17:05

cynistersix


2 Answers

The following works for me in Swift:

pageViewController.clipsToBounds = false
pageViewController.view.clipsToBounds = false
for view in pageViewController.view.subviews {
    view.clipsToBounds = false
}

Similar to Vitaly's answer, but uses a loop to ensure that all subviews are taken care of.

like image 74
Brian Sachetta Avatar answered Oct 25 '22 12:10

Brian Sachetta


View of UIPageViewController has another UIView (more precisely _UIQueuingScrollView) in the subviews hierarchy before actual view of your childViewController. So, to disable clipsToBounds you should do something like that:

UIPageViewController *pageViewController = ...;
pageViewController.view.clipsToBounds = NO;
[[pageViewController.view subviews].firstObject setClipsToBounds:NO];
like image 22
vitalytimofeev Avatar answered Oct 25 '22 12:10

vitalytimofeev