在iOS中使用推/动画动画关闭模态viewController

时间:2013-08-19 08:30:06

标签: ios objective-c uinavigationcontroller uiviewanimation

在呈现时:

CATransition *animation=[CATransition animation];
animation.delegate=self;
animation.duration=0.3;
animation.type=kCATransitionMoveIn;
animation.subtype=kCATransitionFromRight;

UIViewController13 *vc = [[UIViewController13 alloc] init];
[self presentViewController:vc animated:NO completion:nil];
[vc.view.layer addAnimation:animation forKey:@"animation"];

但我不知道如何自定义解雇动画

1 个答案:

答案 0 :(得分:-1)

尝试这样做:

CATransition *animation=[CATransition animation];
animation.delegate=self;
animation.duration=0.3;
animation.type=kCATransitionMoveIn;
animation.subtype=kCATransitionFromRight;

UIViewController13 *vc = [[UIViewController13 alloc] init];

[self presentViewController:vc animated:NO completion:nil];
[self.view insertSubview:vc.view atIndex:0];  //line we add
[self.view.layer addAnimation:animation forKey:@"animation"]; //we edit