Navigation bar height decreased when push ios13 - uinavigationbar

When i move to view controller after making navigationbar.ishidden = false the navbar height decreases and there is a black space between navbar and uiview
And when i move down the notification screen navbar height increase
Code
viewController = PlaceOrderViewController(nibName: "PlaceOrderViewController", bundle: nil)
viewController.hidesBottomBarWhenPushed = true
viewController.navigationController?.isNavigationBarHidden = false
viewController.modalPresentationStyle = .fullScreen
viewController.fromLastScreen = "ProductDetailViewController"
self.navigationController?.pushViewController(viewController, animated: true)

Related

How to fix width of messageInputBar in MessageKit?

I'm presenting the ChatViewController inside a UINavigationViewController as a modal pagesheet, however, as you can see from the image below, the messageInputBar is stuck at the bottom and is occupying the entire width of the screen. Is there a way for me to set the messageInputBar attached to the chat area and with the same width as the chat area?
here is the code i have currently for presenting the ChatViewController
let newVC = UIViewController()
newVC.add
let navVC = UINavigationController(rootViewController: chatVC)]
navVC.isModalInPresentation = true
navVC.viewControllers = [chatVC]
navVC.modalPresentationStyle = .pageSheet
self.present(navVC, animated: true)

How to adjust the size of presented view - Swift 5 (Xcode)

I have a button which will lead a to collection view controller drawDetails_VC.
func showController() {
let drawDetails_VC = DrawDetails(collectionViewLayout: UICollectionViewFlowLayout())
navigationController?.navigationBar.tintColor = UIColor.white
let navController = CustomNavigationController(rootViewController: drawDetails_VC)
present(navController, animated: true, completion: nil)
}
After updating to Swift 5, the presented collection view Page Sheet is not covering the full screen.
I tried hours but didn't get what I want.
How can the presented sheet Page Sheet cover the whole screen and not as above image.
And how can I get programmaticlly the width of the presented Controller Page Sheet
Set your view controller's modal presentation style to .fullScreen or .overFullScreen. Try the code example below.
func showController() {
let drawDetails_VC = DrawDetails(collectionViewLayout: UICollectionViewFlowLayout())
navigationController?.navigationBar.tintColor = .white
let navController = CustomNavigationController(rootViewController: drawDetails_VC)
navController.modalPresentationStyle = .fullScreen
present(navController, animated: true, completion: nil)
}

Custom Navigation Bar Subview does not hide when a new viewcontroller is pushed

So on my HomeViewController I added a custom Navigation Bar #IBOutlet weak var navBar: UIView! and I'm adding it to the navigation bar as:
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.backgroundColor = .clear
self.navigationController?.view.insertSubview(navBar, belowSubview: navigationController!.view)
self.navigationController?.navigationBar.isTranslucent = false
self.edgesForExtendedLayout = []
Now when I push MenuViewController
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "MenuVC") as! MenuViewController
self.navigationController?.pushViewController(vc, animated: true)
This custom navBar is still on the top. I want the default navigation bar to show again as I only want custom navBar on HomeViewController
You have added that custom navbar into the navigationController.view,
that's why it will be seen on every viewController where navigationController is or will be used.
You can do following to solve this
Add that navbar into subview of current UIView
self.view.addSubview(navbar)
Hide the navigationBar from that particular UIViewController
self.navigationController?.setNavigationBarHidden(true, animated: false)
show it to the next ViewController
self.navigationController?.setNavigationBarHidden(false, animated: false)
Either you should remove the customView from your navigationController before pushing your MenuViewController or access the customview using its tag from MenuViewController's viewWillAppear and remove it from superview or hide it

Change Background Color of modal view

I would like to resent an viewcontroller as modal view in size .formSheet. The background color should not be grey transparent, it should be an blur effect.
How I cloud change the background color of view behind modal.
let storyboard = UIStoryboard(name: "DetailViewController", bundle: nil)
if let modalViewController = storyboard.instantiateInitialViewController() as? DetailViewController {
self.definesPresentationContext = true
self.providesPresentationContextTransitionStyle = true
modalViewController.item = item
modalViewController.modalPresentationStyle = .formSheet
modalViewController.modalPresentationCapturesStatusBarAppearance = true
self.present(modalViewController, animated: true, completion: nil)
}
From the viewWillAppear(:) method of your modalViewController, you can access the self.presentationController?.containerView property. You can either change the background color or even add a blur effect view if you want.

Swift ViewController Background getting black with alpha

I'm calling a ViewController as popover when the user presses a button. The View should have black background with alpha 0.5.
But the View is shown as that for a second, than the whole background turns black without alpha. Any idea why?
Thats my popover call:
let popOver = storyboard?.instantiateViewController(withIdentifier: "popOver") as! ViewControllerPopOver
popOver.modalPresentationStyle = .popover
self.present(popOver, animated: true, completion: nil)
I'm trying to set the background color in popovers viewDidLoad() function with following code:
self.view.backgroundColor = UIColor.black.withAlphaComponent(0.5)
For that set modalPresentationStyle to overCurrentContext instead of popover.
let popOver = storyboard?.instantiateViewController(withIdentifier: "popOver") as! ViewControllerPopOver
popOver.modalPresentationStyle = .overCurrentContext
self.present(popOver, animated: true)

Resources