1
我的问题是,我有2个图形动画一个接一个,但他们一起完成。 我想写一个完成块的方法,但或者我做错了什么,或者有另一种方法来做到这一点。完成块图形动画
动画是一个uiview,它移出屏幕(closeView)和viewcontroller关闭的默认动画。 我希望viewcontroller在关闭视图动画时关闭。
这是我做了什么
- (void)closeViewWithCompletion:(void (^) (BOOL finish))handler {
[self closeView];
handler(YES);
}
-(void) closeView{
[self.myview setFrame:CGRectMake(
-self.myview.frame.size.width
, self.myview.frame.origin.y
, self.myview.frame.size.width
, self.view.frame.size.height
)];
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setDuration:.50];
[animation setDelegate:self];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
CALayer *layer = [self.myview layer];
[layer addAnimation:animation forKey:nil];
[UIView animateWithDuration:0.5 animations:^{
[greyMask setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0]];
} completion:^(BOOL finished) {
[greyMask removeFromSuperview];
}];
}
使用:
[vc closeViewWithCompletion:^(BOOL finish) {
[navController popViewControllerAnimated:true];
}
];
显示您需要依次执行的动画代码。 – vaibhav