8

I have VC and I want to push it and to see the VC that under it.

I can do it if I present if modally (Display clearColor UIViewController over UIViewController)

But is it possible to implement this feature via push VC? Or I need to create custom transition ?

Community
  • 1
  • 1
Igor Bizi
  • 81
  • 4

1 Answers1

2

To expand on Wain's comment:

  • you can render the parent view in a UIImage;
  • you 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)
Arnaud
  • 7,259
  • 10
  • 50
  • 71