Reputation: 5092
I have an UIImageView called 'logo' inside a UIView called 'container'. The logo is centred inside the container both horizontally and vertically.
Depending upon the screen size the app is running in the height of the container changes based on constraints. I would like the size of the logo to change proportionally to the height of the container as on the 3.5 inch display it is too large at its normal size.
Can anyone tell me what constraint I should be placing on the logo and/or container to change the logo's size? I'd love to be able to do this without resorting to code as I believe I should be able to set this up in IB. Many thanks.
Upvotes: 0
Views: 84
Reputation: 676
In your xib file, first check the imageview logo is in subview of your container view, then select your imageview and the container view using command key. Once both are selected, go to editor menu and select Heights equally and width equally one by one under pin option. Then select the constraint you just added, go to attributed inspector, change the multiplier in the ratio you want, like 2:3 (it means the height of your logo will be in the ratio of 2:3 of your container view's height if your first item is logo or else set it to 3:2).
Upvotes: 0
Reputation: 956
I hope it can help you ,if you want to know more ,you can read some thing about AutoLayout in WWDC 2014
Upvotes: 1