I'm trying to create a page browser by using a UIPageViewController
in Interface Builder that allows displaying part of the adjacent pages (aka peeking). I've been following a tutorial at http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/ (and ported it into Swift) which is rather straightforward but I can't quite figure out what changes to make to have a page displayed in the UIPageViewController which is smaller than the screen (and centered) and having the adjacent pages appear partly on the screen left and right.
I've tried to resize the page content view controller in IB and with code but the page view controller will still fill the whole screen.
Does anyone know of a tutorial that covers this functionality or what is a good approach to get the desired effect?
This screenshot below from Bamboo Paper shows what I'm trying to achieve...
I was just searching for a good solution to the same feature. I found a nice tutorial on Ray Wenderlich's site titled "How To Use UIScrollView to Scroll and Zoom Content". It illustrates multiple things you can do with
UIScrollView
. The fourth and final is "Viewing Previous/Next Pages" which is your "peek" feature.I haven't implemented this yet, but the key steps seem to be:
UIScrollView
narrower than your screenPaging Enabled
Clip Subviews
UIScrollView
with your pages side by sideUIScrollView
inside aUIView
that fills the width of the screen so that you can capture and pass touches outside the Scroll ViewI rewrite Kevin Jantzer answer in swift 4 and it's works!
Like @davew said, peeking views will need to use
UIScrollView
. I too searched for a way to useUIPageViewController
but couldn't find any resource.Using
UIScrollView
to make this feature was less painful that I had imagined.Here is a simple example to see the basic controls in action.
First: make a
UIViewController
, then in theviewDidLoad
method, add the following code:Update
I have wrapped up this code in a simple ViewController and put it on GitHub
https://github.com/kjantzer/peek-page-view-controller
It is in no way complete, but it's a working start.