Open SikandAlex opened 8 years ago
There's no built-in page control, but you can trivially create one:
let pageControl: UIPageControl = {
let control = UIPageControl()
control.translatesAutoresizingMaskIntoConstraints = false
control.currentPage = 0
control.pageIndicatorTintColor = UIColor.yellowColor()
control.currentPageIndicatorTintColor = UIColor.purpleColor()
return control
}()
Configure it in viewDidLoad
:
pageControl.numberOfPages = 4 // make sure this is correct
view.addSubview(pageControl)
// constrain the page control's location
NSLayoutConstraint(item: pageControl, attribute: .Bottom, relatedBy: .Equal, toItem: contentView, attribute: .Bottom, multiplier: 1, constant: -20).active = true
NSLayoutConstraint(item: pageControl, attribute: .CenterX, relatedBy: .Equal, toItem: view, attribute: .CenterX, multiplier: 1, constant: 0).active = true
Finally, in the scroll view delegate, update the current page:
override func scrollViewDidScroll(scrollView: UIScrollView) {
animator.animate(scrollView.contentOffset.x)
// …
let currentPage = Int(scrollView.contentOffset.x / pageWidth)
pageControl.currentPage = currentPage
}
This if fucking up the animations :) .. It shows the pagecontrol, but its not working properly
@nharbo instead of complaining, you can look into the implementation and if you didn't do that, here is how you can fix it : Just call super.scrollViewDidScroll(scrollView)
and animation should work fine again
Is there an option to enable that page indicator at the bottom of the intro to IFTTT app?