I made one button on the navigation bar. I made it to modal view. But the problem is I can't bring this modal view on the top of the tab bar. What should I do?
In addition, I have used storyboard's segue to present the modal view.
Enter to see storyboard image
Enter to see simulator image
It's hard to tell from the screenshots, but it seems like what you want is for the tab bar to become greyed out just like the background of the view inside the UITabBarController
?
Where are you presenting the modal view from? If view controller A is inside your tab bar controller, then presenting the modal view from A will result in the tab bar not getting grayed out. If you present from the tab bar controller, it should do what you want.
In the presenting view controller's code, instead of
present(modalViewController, animated: true, completion: completion)
try using
tabBarController?.present(modalViewController, animated: true, completion: completion)
(Where modalViewController
and completion
are whatever you mean to use for these arguments, of course.)
If you are using a segue to present the modal controller, then the same concept applies. Move the segue to the tab bar controller and then perform it on the tab bar controller from the presenting view controller.
tabBarController?.performSegue(withIdentifier: "yourSegueIdentifier", sender: tabBarController)
You can simply use the modalPresentationStyle
of your view controller and set it to fullScreen
or overFullScreen
and this will automatically hide the tab bar, whether the view controller is presented from the tab bar or not.
Swift 4 example:
presentedVC.modalPresentationStyle = .overFullScreen
You can check the documentation for more information: UIModalPresentationStyle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With