Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Back button not aligned properly in iOS 11

We started working on our project with Xcode 8.3 and it was all fine till iOS 10 but when we run our same app in iOS 11 the back button is not aligned as intended as you see in the image below

iOS 11 screenshot

But with iOS 10 it's aligned properly

iOS 10 Screenshot

And this what the layout constraint error we are getting

(
"<NSLayoutConstraint:0x600000288200 _UIModernBarButton:0x7f7ef5c87f10.bottom == UILayoutGuide:0x6000005a0380'UIViewLayoutMarginsGuide'.bottom + 64.5   (active)>",
"<NSLayoutConstraint:0x600000287f30 V:[_UIModernBarButton:0x7f7ef5c87f10]-(>=0)-|   (active, names: '|':_UIButtonBarButton:0x7f7ef5c86e60 )>",
"<NSLayoutConstraint:0x600000282030 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x6000005a0380'UIViewLayoutMarginsGuide']-(16)-|   (active, names: '|':_UIButtonBarButton:0x7f7ef5c86e60 )>"

)

like image 222
i70ro Avatar asked Jan 03 '23 08:01

i70ro


1 Answers

For me it is because I use some tricks like below to hide the title

UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -1000), for: .default)

We should not do that, it does not work on iOS 11 and will trigger lots of Auto Layout issue like you post. So check if you have appearance on back button.

If you really want to hide text on the back button, you should do https://stackoverflow.com/a/46889050/1418457

like image 65
onmyway133 Avatar answered Mar 15 '23 07:03

onmyway133