简体   繁体   English

iOS:如何在当前上下文中推送ViewController?

[英]iOS: how to push ViewController over current context?

I have VC and I want to push it and to see the VC that under it. 我有VC,我想推动它并看到它下面的VC。

I can do it if I present if modally ( Display clearColor UIViewController over UIViewController ) 如果我以模态方式呈现( 在UIViewController上显示clearColor UIViewController ),我可以这样做

But is it possible to implement this feature via push VC? 但是可以通过推送VC实现这个功能吗? Or I need to create custom transition ? 或者我需要创建自定义过渡?

To expand on Wain's comment: 扩展Wain的评论:

  • you can render the parent view in a UIImage ; 你可以在UIImage渲染父视图;
  • you then set this image as the background of your new view. 然后将此图像设置为新视图的背景。

Here is a possible implementation in Swift: 这是Swift中可能的实现:

override func viewDidLoad() {

    super.viewDidLoad()

    // render parent view in a UIImage
    UIGraphicsBeginImageContext(self.view.bounds.size);
    self.parent?.view.layer.render(in: UIGraphicsGetCurrentContext()!)
    let viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    // add the image as background of the view
    self.view.insertSubview(UIImageView(image: viewImage), at: 0)

暂无
暂无

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

相关问题 如何在ios 9,目标C中以编程方式导航到另一个具有“当前上下文”演示的viewcontroller - How to navigate programmatically to another viewcontroller with “over current context ” presentation in ios 9, objective C 是否可以随设备旋转在当前上下文(UIModalPresentationStyleOverCurrentContext)上以模态形式呈现的视图控制器? - Can a viewcontroller presented modally over current context (UIModalPresentationStyleOverCurrentContext) be rotated with device? 在当前上下文上呈现视图控制器是模态的并且不能正确旋转 - Presenting viewcontroller over current context is modal and does not rotate correctly 如何从另一个推一个ViewController - How to Push a ViewController from Left Over another 如何在iOS中从rootViewController推送Viewcontroller - How to push Viewcontroller from rootViewController in iOS 如何在iOS中找到当前可见的ViewController - How to find current visible viewController in iOS swift如何通过解除当前的viewcontroller将数据推送到其他视图? - swift how to push data to other view by dismissing the current viewcontroller? Swift:关闭ViewController在当前上下文中显示图片时,屏幕会不时冻结 - Swift: Screen Freezing from time to time when Dismissing a ViewController displaying a picture over the current context 无法在iOS中再次推送ViewController - Can not push viewcontroller again in IOS iOS在当前ViewController中设置BackButton - iOS set BackButton in the current ViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM