Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safe Area increase itself after hide tab bar, but dont decrease if i show tab bar again

i have a view controllers in a tab bar controller with constraints to bottom safe area, but one of them i must hide tab bar i use this self.tabBarController?.tabBar.isHidden = true this increase the safe area

But if i need to move to another i show back tab bar self.tabBarController?.tabBar.isHidden = false But safe area don't decrease by itself, making view contents behind tab bar

To make it clear i put a red view pinned to bottom safe area, next i go to view and hide tab bar enter image description here

this is when it come back to this view and show tab bar again, safe area increased below tab bar, that's why red square are more below enter image description here

like image 531
Abraham Rangel Avatar asked Nov 29 '25 16:11

Abraham Rangel


1 Answers

It appears to be a bug in iOS. SafeArea doesn't change to account for tabBar, after hiding / showing it.

You can work around it by anchoring your view to superview and adjusting for tabBar manually. For example, if you want to anchor a tableView to a tabBar it would look like this

    if let tabBar = tabBarController?.tabBar {
        tabBar.isHidden = true
        tableViewBottomConstraint.constant = tabBar.frame.height
    }
like image 87
Senõr Ganso Avatar answered Dec 01 '25 09:12

Senõr Ganso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!