我想用下面的動畫去除子視圖。但是,當我點擊一個按鈕來運行代碼時,視圖立即被刪除。有誰知道這裏發生了什麼。用ainimation去除子視圖
感謝,
CGRect rect=[self.view viewWithTag:10].frame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDidStopSelector:@selector(removeLayer)];
[[self.view viewWithTag:10] setFrame:CGRectMake(rect.origin.x, btn.frame.origin.y, rect.size.width, 0)];
[UIView animateWithDuration:1.0 animations:^{[[self.view viewWithTag:10] setFrame:CGRectMake(rect.origin.x, btn.frame.origin.y, rect.size.width, 0)];} completion:^(BOOL finished){[[self.view viewWithTag:10] removeFromSuperview];}];
[UIView commitAnimations];
-(void)removeLayer{
[[self.view viewWithTag:10] removeFromSuperview];
}
不要忘了委託;)'[UIView的setAnimationDelegate:自我]' – beryllium