Reputation: 1
I have read tutorials about the auto layout but i just couldn't understand the basic things, where they all deals with technical ways to handle Xcode, i couldn't find a simple, clear , explanation to it .
So I will ask 2 basic questions, for 1 problem, a simple problem.
Problem: I have created UIImageView
in storyboard
, inside a view controller .
I would like this view, to always be in the screen size, no matter what iPhone it is .
float width= [UIScreen mainScreen].bounds.size.width; float height=[UIScreen mainScreen].bounds.size.height; self.backImage.frame=CGRectMake( 0, 0 , width, height) ;
Why is this not working(because the image view is checked for auto layout ? )
How to define layouts in storyboard
, for this view, to always cover the screen size exactly ?
What if after i set constrains, i would like to set some effect for this view- to move, in code, for example setting the image view size to be 1.5 screen size and centered ?
Upvotes: 0
Views: 3281
Reputation: 861
Remove any other constraints that define the width or the height of the UIImageView
. Open the Pin Tool constraints tab (Interface builder, at the bottom right, third button from the left), and set all the Spacing to nearest neighbour
constraints to 0. Now click Apply Constraints, and update your frame.
Upvotes: 2