UILabel jumps briefly when navigation bar visibility changes despite autolayout constraints

I’m working on an iOS app where I have a text label that’s positioned using autolayout constraints. Everything works fine normally, but there’s a weird issue that happens when I toggle the navigation bar visibility.

When the navigation bar gets hidden or shown (I trigger this by tapping anywhere on the screen), the label jumps around for a split second before settling into its final position. This twitching effect looks really bad and I can’t figure out how to fix it.

The label should stay in exactly the same spot no matter what happens with the navigation bar. I think the problem might be related to the animation that happens when hiding/showing the navigation bar. It seems like autolayout gets confused during the transition.

I’ve set up the constraints to position the label relative to the safe area, but maybe I’m missing something. Has anyone else run into this issue before? What’s the best way to prevent UI elements from jumping around when the navigation bar animates in and out?

This happens because the system recalculates safe area insets during navigation bar animations, making constraint layouts update bit by bit. I ran into this exact issue - labels would flicker during transitions. What worked for me was temporarily disabling constraint animations by overriding the view controller’s transition coordinator. You can grab the transition coordinator when the nav bar state changes and use it to sync your layout updates with the system animation. You could also manually handle the constraint constants by calculating the offset difference and adjusting them before the animation kicks off. This stops the automatic recalculation that makes everything jump around.

The jumping happens because safe area constraints recalculate while the navigation bar transitions. I fixed this by switching to view constraints instead of safe area constraints for elements that shouldn’t move. The safe area keeps changing size as the nav bar shows/hides, so the layout engine repositions your label mid-animation. You can also wrap your nav bar toggle in UIView.performWithoutAnimation - this stops the intermediate layout calculations that cause the jump. Check for constraint priority conflicts too, since those can make animations behave unpredictably.

Had the same issue! Your constraints are updating at different times during the animation. Wrap your navbar toggle in an animation block and call view.layoutIfNeeded() inside it. This forces the layout to update smoothly instead of jumping around.