IOS: how to click ViewController on current context?

I have a VC, and I want to click it and see the VC that is under it.

I can do this if I imagine if modally ( Show clearColor UIViewController via UIViewController )

But is it possible to implement this function through push VC? Or do I need to create a custom transition?

+6
source share
1 answer

To expand a Wain comment:

  • You can display the parent view in UIImage ;
  • then set this image as the background of your new view.

Here is a possible implementation in 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) 
0
source

All Articles