私は以下のようなアニメーションを使用してiOSのマーキーテキストに取り組んでいます:
最初の方法:
-(void)startScrolling {
CGRect rect ;
rect = self.titleView.frame;
rect.origin.x = -self.titleView.frame.size.width;
self.titleView.frame = rect;
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:13];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startScrolling)];
// Update end position
CGRect rect ;
rect = self.titleView.frame;
rect.origin.x = [[UIScreen mainScreen] bounds].size.width;
self.titleView.frame = rect;
[UIView commitAnimations];
}
2番目の方法:
[UIView animateWithDuration:13
delay:0
options:UIViewAnimationOptionCurveLinear
animations:^{
CGRect rect ;
rect = self.titleView.frame;
rect.origin.x = -self.titleView.frame.size.width;
self.titleView.frame = rect;
}
completion:^(BOOL finished) {
CGRect rect ;
rect = self.titleView.frame;
rect.origin.x = [[UIScreen mainScreen] bounds].size.width;
self.titleView.frame = rect;
[self startScrolling];
}
];
最初の方法は正しく機能することです。2番目の方法の問題は、アニメーション中に加速が追加されることです。取得しないでください
ブロック使用中に加速が追加される理由。インターネットで検索していますが、まだ行き詰まっています。この問題について何かアイデアはありますか?