iOS开发:用CATransition改变PUSH的弹出方向

2018-03-28  本文已影响0人  此笙吥涣

问题:项目中页面跳转需要用模态效果(页面上下进入推出),但是进来的页面还还是需要导航。

使用的是导航跳转(左右出现)页面,效果是模态效果(上下)出现页面

PUSH 推入:模拟出模态弹出效果

TWOViewController *vc = [TWOViewController new];

CATransition *transition = [CATransition animation];

transition.duration = 0.25;

transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];

transition.type = kCATransitionPush;

transition.subtype = kCATransitionFromTop;

transition.delegate = self;

[self.navigationController.view.layer addAnimation:transition forKey:nil];

//隐藏跳转的页面的导航条:实质是PUSH,所以用POP 推出

[self.navigationController pushViewController:vc animated:NO];

}
pop 弹出:模拟出模态弹出效果

CATransition *transition = [CATransition animation];

transition.duration = 0.25;

transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];

transition.type = kCATransitionPush;

transition.subtype = kCATransitionFromBottom;

transition.delegate = self;

[self.navigationController.view.layer addAnimation:transition forKey:nil];

self.navigationController.navigationBarHidden = NO;

[self.navigationController popViewControllerAnimated:NO];

}

上一篇下一篇

猜你喜欢

热点阅读