简体   繁体   English

如何推送具有透明背景的新viewController?

[英]How to push a new viewController with Transparent Background?

I wanted to Push New View Controller with Transparent Background on top of one View Controller which is already shown. 我想在已经显示的一个View Controller的顶部推送具有透明背景的新视图控制器。 I know How to PRESENT but I wanted to PUSH new View Controller. 我知道如何呈现,但我想推动新的View Controller。

UIViewController *controller = [[UIViewController alloc] init];
self.definesPresentationContext = YES;
controller.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:controller animated:YES completion:^{}];

You need to give memory to your ViewController and set to RootController of UINavigationController . 您需要为ViewController提供内存并设置为UINavigationController的 RootController After that, you can push it from your current controller... 之后,您可以从当前控制器推送它...

UIViewController *yourViewController = [[UIViewController alloc] init];
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:yourViewController];
[self presentViewController:navigationController1 animated:YES completion:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM