IFTTT / RazzleDazzle

A simple keyframe-based animation framework for iOS, written in Swift. Perfect for scrolling app intros.
http://ifttt.github.io
MIT License
3.36k stars 293 forks source link

Is it possible to have pagination? #14

Open tundsdev opened 8 years ago

tundsdev commented 8 years ago

Hi i was wondering if you've developed pagination within the framework so that there's circles at the bottom of the screen to show the user the current view which they are on? Like the image attached.

screen shot 2015-12-13 at 20 15 39

maxmeyers commented 8 years ago

This is a great idea! We'd welcome a pull request for it, but not something we're planning to work on soon.

martnst commented 8 years ago

+1

vincent-peng commented 8 years ago

+1

dareApple commented 8 years ago

+1

andreyrd commented 8 years ago

You can add a UIPageControl manually and wire it up manually like so:

class PagedViewController: AnimatedPagingScrollViewController {

    // Set this up using your preferred method, make sure it's on all pages
    private let pageControl: UIPageControl

    override func scrollViewDidScroll(scrollView: UIScrollView) {
        super.scrollViewDidScroll(scrollView)
        pageControl.currentPage = Int(pageOffset + 0.5)
    }
}

I add 0.5 to the offset so that the page control changes right in between pages.

Edit: Added super.scrollViewDidScroll(scrollView) so that we don't take away whatever RazzleDazzle does on scroll. :)

martnst commented 8 years ago

as @andreyrd showed it is actually super easy to add a UIPageControl. I did so myself (just never managed to post it here). Therefor my suggestion is to not add a build in UIPageControl, but (since it's common) to provide a tutorial how to add a fully customizable UIPageControl yourself. I guess a wiki page would be the best place to put it. I'll be happy to share my implementation if a tutorial / how to is the way to move with this issue.

nharbo commented 7 years ago

Adding override func scrollViewDidScroll(scrollView: UIScrollView) { }

ruins the animations.. At least it does for me.. So any other suggestions? :)

vincent-peng commented 7 years ago

Here what I did previously, hope that would help,

@IBOutlet weak var introPageControl: UIPageControl!

// Page Change Listener
internal override func scrollViewDidScroll(_ scrollView: UIScrollView) {
    super.scrollViewDidScroll(scrollView)

    let screenSize: CGRect = UIScreen.main.bounds
    if scrollView.contentOffset.x.truncatingRemainder(dividingBy: screenSize.width) == 0 {
        let index = scrollView.contentOffset.x / screenSize.width
        // Set the new page index to the page control
        introPageControl.currentPage = Int(index)
    }
}