Reputation: 25958
I want to show one view controller with clear background color using navigation controller - swift.
let nextViewController = SettingViewController(nibName: "SettingViewController", bundle: nil)
nextViewController.view.backgroundColor = UIColor.clearColor()
nextViewController.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
self.navigationController?.pushViewController(nextViewController, animated: true)
but its not working . Above code is working when i am presenting second view but not working with navigation controller .
Upvotes: 3
Views: 1507
Reputation: 25958
I have tried with many ways but did not get any feasible solution. Actually problem with the navigation controller is that current view animation start from left to right moving with nextViewController and in iOS-8 there is no option to clear view controller background(actually you can but another white color object is appearing at place of this). So we cant use navigation view in this scenario.
Problem with Present view controller : We can not use present view controller if your application is running on Navigation controller because you cant use push other view controller after presenting any view controller on it so this solution is not useful in this scenario.
Solution : Finally i have added nextViewController view on present controller with animation. But the condition is take nextViewController reference globally otherwise nextViewController button action and some other action will not work and application will crashed. So just take global reference of nextViewController and add nextViewController view on presentViewController with animation as you want and remove whenever you want to remove (now you can put view opacity and color as you want) . This is working perfectly as i wanted.
Upvotes: 1