开发者

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:

  1. implement the delegate methods for responding to scroll ending.
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜