Reputation: 1107
I have universal app. Subview is rectangle which is positioned inside View.
How can I keep it centered and make it automatically adopt it's width depends on screen width ?
e.g.
Upvotes: 0
Views: 192
Reputation: 22374
As you said you want this only in portrait means its not an adaptive layout....So its fairly simple now....
As you want the width of object resize according to screen width... Just pinned right and left edges of screen to adopt width accordingly (or use equal width) As you not mention about height...so give fixed height to object....
And for making the object to the center of the view controller ....
Use center vertically and horizontally....and you are done..
Here is the image of what I said for better understanding
Upvotes: 0
Reputation: 3442
In order to center a view within it's superview, you need to check Horizontal Center in Container
and Vertical Center In container
in the Autolayout Align section:
You could also make use of Size Classes :
With size classes, a storyboard or xib file can be used for any available screen area. You build your interface as it will look in most sizes, then update only the parts that need to change when the available screen size changes.
Upvotes: 1