4

how to transparent background when pushViewcontroller?? just like.. modal view over full screen (programmatically, not using storyboard, not using present modal)


first view controller > Button Action >

    let transition = CATransition()
    transition.duration = 0.5
    transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
    transition.type =  kCATransitionPush //kCATransitionFade
    transition.subtype = kCATransitionFade

    self.navigationController?.view.layer.add(transition, forKey: nil)

    let testVC = SecondViewController()

    if let existVC = self.navigationController {
        existVC.pushViewController(testVC, animated: false)
    }

second View Controller

super.viewDidLoad()
self.view.backgroundColor = UIColor.clear

The result is... black background. how to transparent background??

nsinvocation
  • 7,559
  • 3
  • 41
  • 46
Michael Park
  • 105
  • 1
  • 2
  • 5
  • 2
    Just use present view controller instead of push – Miknash Jan 05 '17 at 14:41
  • 2
    Hacking the animation of `UINavigationController` never works reliably. The controller is replaced there, therefore you cannot achieve transparency. – Sulthan Jan 05 '17 at 14:42

0 Answers0