Tell When a UIPageViewController is Scrolling (for Parallax Scrolling of an Image)

后端 未结 8 1944
灰色年华
灰色年华 2020-12-13 04:43

I am trying to make an effect similar to that found in the new Yahoo weather app. Basically, each page in the UIPageViewController has a background image, and w

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 05:03

    What you are looking for is called parallax scrolling, you can find several libraries that can help you with that.

    Edit: Matt is right this is not an answer, only a hint. Anyway let's complete it:

    For animating a background image that lay behind your UIPageViewController you should use the delegate methods that it offer:

    -[id pageViewController:willTransitionToViewControllers:]
    -[id pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted:]
    

    With these two methods you can calculate the percentage of the scrolling (you should store your controllers in your array to know at which controller you scrolled to and get the percentage)

提交回复
热议问题