第一種方法:,使用監聽
UIView beginAnimations
[UIView beginAnimations:nil context:nil]; //代理,監聽對象 [UIView setAnimationDelegate:self];
//removeCover 是動畫執行完後要調用方法 [UIView setAnimationDidStopSelector:@selector(removeCover)]; self.coverBtn.alpha =0.0; [UIView commitAnimations];
-(void)removeCover { [self.coverBtn removeFromSuperview]; self.coverBtn=nil; }
[UIView animateWithDuration:1.0 animations:^{ self.coverBtn.alpha= 0.0; self.iconbtn.frame = self.oldPicFrame; } completion:^(BOOL finished) { [self.coverBtn removeFromSuperview]; self.coverBtn =nil; }];