iOS: scrollView paging index
I have a scrollView with 4 page; I want to change it's background color at every page; then I want to know index page value. For example, if I have page 1, I want to know that I have index 1 then background must be red or if I have page 3, I want to know that I have index 3 and background color must be blue.
then I want to do an "if" where I control if my current page have index 1, or index 2, or index 3开发者_高级运维.....
The page index is found by: scrollview.contentOffset.x / scrollview.frame.size.width
.
To set the background color you can either:
- implement the delegate methods for responding to scroll ending.
- Insert subviews with their background colours set at the page index offsets.
There is problem with option one. When transitioning between pages the background colour will be incorrect until the scrolling ends.
精彩评论