プロパティをアニメーション化する必要がありbounds
ます。実際、それはcontentOffset
プロパティが舞台裏で使用しているものです。
例:
CGRect bounds = scrollView.bounds;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"bounds"];
animation.duration = 1.0;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.fromValue = [NSValue valueWithCGRect:bounds];
bounds.origin.x += 200;
animation.toValue = [NSValue valueWithCGRect:bounds];
[scrollView.layer addAnimation:animation forKey:@"bounds"];
scrollView.bounds = bounds;
興味があれば、この情報を取得するために使用した方法は次のとおりです。
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[scrollView setContentOffset:CGPointMake(200, 0) animated:NO];
[UIView commitAnimations];
NSLog(@"%@",scrollView);
NSLog
呼び出しは次を出力します。
<UIScrollView: 0x860ba20; frame = (-65.5 0; 451 367); clipsToBounds = YES; autoresize = W+RM+TM+H; animations = { bounds=<CABasicAnimation: 0xec1e7c0>; }; layer = <CALayer: 0x860bbc0>; contentOffset: {246, 0}>
animations
スニペットには、アクティブなすべてのアニメーションが一覧表示されます。この場合は{ bounds=<CABasicAnimation: 0xec1e7c0>; }
.
お役に立てれば。