Reputation: 251
I'm having a few issues with Autolayout and trying to make my app's layout to look decent on both screen sizes. Here's how it looks on a 4-inch:
But,here's how it looks on a 3.5-inch:
I want the UIImageView to stay pinned to the top, and the Watch/Listen buttons to stay together pinned to the bottom (with the same spacing).
And, I want the Title/Speaker/Date labels to be in the middle between the UIImageView and buttons.
Thoughts on how I can do this with Autolayout? Or will I need to do some research on coding the layout?
Upvotes: 0
Views: 2014
Reputation: 1301
I'm a bit late to this question, but I think it would be much simpler to use a containing view. Create a view that constrains to the bottom of the UIImageView and to the top of the UIButton (and to the left and right edge of the screen). Then place your UILabels inside that view.
You can either center the middle label horizontally and vertically and then constrain your other labels off of that, OR you can create another subview that doesn't have a set height or width, but pins to the labels within it to get its height and width. Then you could just center that view horizontally and vertically within the first containing view you make.
Upvotes: 0
Reputation: 535526
Easiest way to set this up entirely in Interface Builder is to use invisible spacer views, for the reasons that I explain here: https://stackoverflow.com/a/20865342/341994
Upvotes: 1
Reputation: 4012
I see two possibilities:
add this to your pch file:
'#define IS_IPHONE_5 (fabs((double) [[UIScreen mainScreen ] bounds].size.height - (double) 568) < DBL_EPSILON)`
and in code:
self.spacing.constant = IS_IPHONE_5 ? value1 : value2;
[self.view setNeedsLayout];
Upvotes: 0