转发自:http://blog.youkuaiyun.com/huifeidexin_1/article/details/7597868
setAnimationDidStopSelector:
设置消息给动画代理当动画停止的时候。
+ (void)setAnimationDidStopSelector:(SEL)selector
参数
selector
当动画结束的时候发送给动画代理。默认值是NULL。这个选择者须有下面方法的签名:animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context。
animationID
一个应用程序提供的标识符。和传给beginAnimations:context: 相同的参数。这个参数可以为空。
finished
如果动画在停止前完成那返回YES;否则就是NO。
context
一个可选的应用程序内容提供者。和beginAnimations:context: 方法相同的参数。可以为空。
讨论
这个方法在动画块外没有任何效果。使用beginAnimations:context: 类方法来开始一个动画块并用commitAnimations类方法结束。默认值是NULL。
代码:
- (void)startAnimation
{
_pmdScrollView.contentOffset = CGPointMake(0.0f, 0.0f);
[UIView beginAnimations:@"MarqueeBarAniamation" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:8];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
_pmdScrollView.contentOffset = CGPointMake(_pmdScrollView.contentSize.width - 250.0f, 0.0f);
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
if ([animationID isEqualToString:@"MarqueeBarAniamation"]){
if ([finished boolValue] > 0){
[self startAnimation];
}
}
}