Skip to content

Instantly share code, notes, and snippets.

@srfunksensei
Last active February 6, 2019 08:15
Show Gist options
  • Select an option

  • Save srfunksensei/8c3512f012614af6e69c0d83da3825f3 to your computer and use it in GitHub Desktop.

Select an option

Save srfunksensei/8c3512f012614af6e69c0d83da3825f3 to your computer and use it in GitHub Desktop.
CarouselSample
class CarouselPageViewController: UIPageViewController {
fileprivate var items: [UIViewController] = []
override func viewDidLoad() {
super.viewDidLoad()
dataSource = self
populateItems()
if let firstViewController = items.first {
setViewControllers([firstViewController], direction: .forward, animated: true, completion: nil)
}
}
fileprivate func populateItems() {
let text = ["πŸŽ–", "πŸ‘‘", "πŸ₯‡"]
let backgroundColor:[UIColor] = [.blue, .red, .green]
for (index, t) in text.enumerated() {
let c = createCarouselItemControler(with: t, with: backgroundColor[index])
items.append(c)
}
}
fileprivate func createCarouselItemControler(with titleText: String?, with color: UIColor?) -> UIViewController {
let c = UIViewController()
c.view = CarouselItem(titleText: titleText, background: color)
return c
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment