Skip to content

Commit

Permalink
ATPagingView: Smoother rotation animation
Browse files Browse the repository at this point in the history
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
andreyvit committed Apr 19, 2011
1 parent 56edb84 commit 5333726
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ATPagingView/ATPagingView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5333726

Please sign in to comment.