Permalink
Browse files

ATPagingView: Smoother rotation animation

Two changes affect the smoothness of animation:

1) Page positioning during animation did not take
interpage gap into account properly. Fixed.

2) Turns out, autoresizing mask still has effect
during animation, even though the view has a
custom layoutSubviews. (The autoresizing mask is
applied on every frame. For some weird reason,
this results in a different animation path.)
  • Loading branch information...
1 parent 56edb84 commit 533372664af43471e76efae6a93259e98b5a1217 @andreyvit committed Apr 19, 2011
Showing with 2 additions and 1 deletion.
  1. +2 −1 ATPagingView/ATPagingView.m
@@ -52,6 +52,7 @@ - (void)commonInit {
self.clipsToBounds = YES;
_scrollView = [[UIScrollView alloc] initWithFrame:CGRectZero];
+ _scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_scrollView.pagingEnabled = YES;
_scrollView.backgroundColor = [UIColor blackColor];
_scrollView.showsVerticalScrollIndicator = NO;
@@ -249,7 +250,7 @@ - (void)willAnimateRotation {
//
// So we set the new size, but keep the old position here.
CGSize pageSize = _scrollView.frame.size;
- [self viewForPageAtIndex:_currentPageIndex].frame = CGRectMake(_scrollView.contentOffset.x, 0, pageSize.width - _gapBetweenPages, pageSize.height);
+ [self viewForPageAtIndex:_currentPageIndex].frame = CGRectMake(_scrollView.contentOffset.x + _gapBetweenPages/2, 0, pageSize.width - _gapBetweenPages, pageSize.height);
}
- (void)didRotate {

0 comments on commit 5333726

Please sign in to comment.