Click on the second view controller with clear background in fast

I want to show a single view controller with a clear background color using a navigation controller - fast.

let nextViewController = SettingViewController(nibName: "SettingViewController", bundle: nil)
    nextViewController.view.backgroundColor = UIColor.clearColor()
    nextViewController.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
    self.navigationController?.pushViewController(nextViewController, animated: true)

      

but doesn't work. The code above works when I present the second view, but not working with the navigation controller.

+3


source to share


1 answer


I tried many ways but didn't get any possible solution. Actually the problem with the navigation controller is that the animation of the current view starts from left to right, moving with the nextViewController, and in iOS-8 there is no way to clear the background of the control controller (actually you can, but another white color appears at this place an object). Therefore, we cannot use the navigation view in this scenario.

Problem with existing view controller: we cannot use the current view controller if your app is running on a navigation controller because you cannot push another view controller after a view of any view controller on it, so this solution is not useful in that scripts.



Solution: Finally, I added the nextViewController to the current controller with animation. But the condition accepts the next nextViewController recommendation globally, otherwise the nextViewController button action and some other actions won't work and the app will crash. So just take the nextViewController global reference and add the nextViewController view to the presentViewController with animation as you wish and remove when you want to remove (you can now put the transparency and color of the view as you want). This works just fine as I wanted.

+1


source







All Articles