Autolayout: Origin and Size Should Change According to Width and Height Factor

Autolayout: origin and size should change according to width and height factor

As pre your question you can set this constraints to your UIButton.


You are not required to change the constraint which you have set for height and width of UIButton.


1.) You need to set horizontal space to Button.Leading and Superview.Trailing.

Set constant=0, Priority=1000 and Multiplier=100:320 as I've set in below image.

Sample Image


2.) You need to set horizontal space to Button.Top and Superview.Bottom.

Set constant=0, Priority=1000 and Multiplier=100:568 as I've set in below image.

Sample Image


Result


Sample Image

Sample Image

Sample Image

Hope this solves your problem.

Change view width with autolayout and size class enabled

If you want the dimensions of your view to follow the same width as the one of the iPhone it's running on, in Interface Builder, position the view, size it so that it basically looks as you want it to look, and then add the constraints, ctrl drag from your view to it's superview and add "Leading space to container margin" and "Trailing space to container margin" constraints.

Is it safe to change a view's frame if it has translatesAutoresizingMasksIntoConstraints=YES

If the view is configured with constraint-based layout, you shouldn't adjust the frames manually because it will get changed at the next layout pass. You can easily accomplish this by setting a maximum width constraint on the view.

If it's not configured with constraint-based layout, your current solution will work, although it's bad practice for a view to modify its own frame (a view's frame should be modified by its superview or its view controller).

AutoLayout to keep view sizes proportional

This can be resolved by adding one more dummy view(dummyView) with its constraints set to Fixed width, height and aligned to centerX of Superview.Then add left view and right view Horizontal spacing constraint to dummyView.

Sample Image Sample Image

Autolayout proptional constrain not working properly iOS

As you have explained that you want to increase/decrease size of image according to device size.

I have tried to solve the issue. Refer http://s000.tinyupload.com/index.php?file_id=54760890874471716136

Hope this will help you.

UITableViewCell.contentView reports wrong width

Incase someone bumps into this, the culprit was the tableview. When I pinned it's edges to the superview, the cells started to work correctly.



Related Topics



Leave a reply



Submit