1,使用 CAAnimation 实现模态控制器的push效果,
// 要显示的控制器 BusinessWebController * businessVC = [[BusinessWebController alloc] init];/*** addSubView的方式*/// [mainVC addChildViewController:businessVC];// [mainVC.view addSubview:businessVC.view];/// 在view的layer上 addAnimation (加 、 被加)// [mainVC.view.layer addAnimation:transition forKey:nil];// 切换跟控制器的方式 [UIApplication sharedApplication].keyWindow.rootViewController = businessVC; [UIApplication sharedApplication].keyWindow.backgroundColor = [UIColor whiteColor];// 构建push效果动画 CATransition *transition = [CATransition animation]; transition.duration = 0.15; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; transition.type = kCATransitionPush; transition.subtype = kCATransitionFromRight; transition.delegate = self; [businessVC.view.layer addAnimation:transition forKey:nil];
时间: 2024-10-10 06:50:12