[英]UIView animation completion callback?
動畫制作完成后,我可以設置要調用的功能嗎? 我想淡出UIView
,然后將其從superView
刪除。
動畫塊是在iOS4中引入的。 Apple建議您使用這些,新方法通常會要求使用完成塊來代替回調。 例如:
[UIView animateWithDuration:0.5f
delay:0.0f
options:UIViewAnimationCurveEaseInOut
animations:^{
[myView setAlpha:0.0f];
}
completion:^(BOOL finished) {
[myView removeFromSuperview];
}];
是的,這很容易:
配置動畫時
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(myAnimationStopped:finished:context:)];
並定義您的方法,例如:
-(void)myAnimationStopped:(NSString *)animationID
finished:(NSNumber *)finished
context:(void *)context {
// fancy code here
}
當然,不必一定是self
,也不需要那種方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.