我有一个基于导航的应用程序,我想更改推送和弹出动画的动画。我该怎么做?
当我推送任何viewController时,它表示为pop,当我弹出任何viewController时,它表示为push。
答案 0 :(得分:2)
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype=kCATransitionFromRight;
kCATransitionFromLeft or kCATransitionFromRight
[self.navigationController.view.layer addAnimation:transition forKey:nil];
在推送视图控制器以进行自定义动画
之前添加此项答案 1 :(得分:1)
-(void)pushViewController:(UIViewController *)viewController{
float width = self.frame.size.width;
float height = self.frame.size.height;
[viewController.view setFrame:CGRectMake(width, 0.0, width, height)];
[self addSubview:viewController.view];
[UIView animateWithDuration:0.33f
delay:0.0f
options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
animations:^{
[viewController.view setFrame:self.frame];
[self setFrame:CGRectMake(0.0, 0.0, width, height)];
}
completion:^(BOOL finished){
}];
}