Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Autolayout - Position view correctly below translucent navigation bar

In my storyboard, I have a UIImageView that I'd like to place at a fixed distance below a translucent navigation bar. I have the simulated top bar for the view controller set to the translucent bar, and the constraint I have now says "Top Space to Superview Equals 52," 8 points below the bar.

However, when the view rotates to landscape, the navigation bar shrinks to 34 points, and the image view is still at 52 points like it was in portrait.

What constraint can I use in IB to place the image view at 8 points below the navigation bar no matter how tall the bar is?

Thanks!

like image 460
architectpianist Avatar asked Oct 22 '22 07:10

architectpianist


1 Answers

Select your UIImageView and control-drag to the Top Layout Guide to create a constraint. If you're not familiar with the Top Layout Guide, you can select it in the structure view on the left.

like image 179
Nestor Avatar answered Nov 01 '22 19:11

Nestor