Jun 21, 2020
If you ever want something like this:
simply add this line to your viewController
navigationController?.additionalSafeAreaInsets.top = 100
// where 100 is the extra space
To see the code in action, I attached the following function to the BLUE slider
@IBAction func sliderSlided(_ sender: Any) {
let top: CGFloat = (CGFloat(200 * ((sender as? UISlider)?.value ?? 1) - 0.5))
navigationController?.additionalSafeAreaInsets.top = top
}
Also notice that when the NavigationBar changes, the slideIndicator changes too, indicating change in the view's size.
I also add a RED slider with the following function:
@IBAction func slider2Slided(_ sender: Any) {
let top: CGFloat = (CGFloat(100 * ((sender as? UISlider)?.value ?? 1)))
additionalSafeAreaInsets.top = top
}
Notice how RED slider resizes both the content and the Navigation Bar. Moiving the BLUE slider after the RED to configure the navigationBar.
AdditionalSafeAreaInsets is traditionally use to change the safeAreaInset of the ViewController.
Confusians
© 2015 - 2025