Monday 8 September 2014

Relationship between contentSize, contentOffset and animation

UIScrollView's core has 2 properties which manage the visible portions of the scroll view on the screen.

- When we set contentSize
  • if the contentOffset is beyond the new contentSize the contentOffset is reset.
  • else the contentOffset is not changed. 
If you want to animate the contentOffset in the case when your contentOffset goes beyond contentSize then:

[[UIView animateWithDuration:0.2
                animations:^{
                                   self.contentSize = CGSizeMake(self.scrollViews.count *                      self.bounds.size.width, self.bounds.size.height);
                                     }
                 completion:NULL];


1 comment:

  1. Nice post . Thanks for share.
    If you love gaming for unity games kindly visit….
    mobile app & game development

    ReplyDelete