I am trying to make a View that acts like Apple's springboard (Where all the apps are) so I can swipe to the right or left and show another set of items. I'm mainly having issues with the constraints and getting all the icons to appear normally across all screen sizes. I'm using just a basic UIView controller to try and accomplish this. What is the best way to use constraints with an array of images like Apple's springboard?
Thanks for your help.
In the storyboard, I have dragged a UIPageViewController
and two UIViewController
. I have subclassed UIPageViewController
to MyPageViewController
.
The rest is done by code in MyPageViewController.swift:
override func viewDidLoad() {
super.viewDidLoad()
// can't be done in storyboard (-_-)
delegate = self
datasource = self
setViewControllers([page1, page2], direction: .forward, animated: false, completion: nil)
}
(where page1
and page2
are the two other UIViewController of your storyboard)
In case you wonder how to get page1 (after setting an identifier in storyboard):
let page1 = UIStoryboard(name: "MyStoryboard", bundle: nil).instantiateViewController(withIdentifier: "page1")