第一种方法:,使用监听
UIView beginAnimations
方法如下:
[UIView beginAnimations:nil context:nil];
//代理,监听对象
[UIView setAnimationDelegate:self];
//<span style="font-family: Arial, Helvetica, sans-serif;">removeCover 是动画执行完后要调用方法</span>
[UIView setAnimationDidStopSelector:@selector(removeCover)];
self.coverBtn.alpha =0.0;
[UIView commitAnimations];
removeCover:
-(void)removeCover
{
[self.coverBtn removeFromSuperview];
self.coverBtn=nil;
}
第二种方法:使用block, UIView animateWithDuration
[UIView animateWithDuration:1.0 animations:^{
self.coverBtn.alpha= 0.0;
self.iconbtn.frame = self.oldPicFrame;
} completion:^(BOOL finished) {
[self.coverBtn removeFromSuperview];
self.coverBtn =nil;
}];