iOS App layout is wrong with calling status bar

2019-05-06 16:18发布

问题:

Faced with an issue with status bar during active call and application layout.

I'm using autolayouts. When I run the app, and then start a call, all works fine, the UI is scaled properly with changed status bar.

But if I first start a call and then run the app, application screens moved for 20pt to the bottom, like if they did not react on new status bar. And even if I will turn off the call, the UI will be moved to bottom.

Maybe somebody know how o fix that?

回答1:

This is easy, when you gave the constraints to your views you gave them with respect to the TLG(Top Layout Guide) of your View Controller. Now when a call occurs the status bar resizes due to which the TLG changes and resulting of which the views move.

To prevent this you might wanna give the top constraint of your view with respect to the Top of the superview. Now in this case views's constraints are not dependent on TLG which changes on change of status bar size, therefore they do not change during a call or any other event which change the size of the status bar.