Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone autoresizingmasks

I've been experiencing problems with designing views so that the subviews behave the way I want when using autoresizingmasks (for example, if the status bar size changes, when using the phone as a hotspot etc.). Is there any good documentation that I should definitely read? Apple documents don't seem to help me at least not without some heavy testing of my own.

like image 726
mbord Avatar asked Feb 21 '12 12:02

mbord


People also ask

What is Autoresizingmask in IOS?

An integer bit mask that determines how the receiver resizes itself when its superview's bounds change.

What is auto resizing?

Autoresize automatically resizes an imported animation to your composition's size. In case you're importing in an empty project the resolution will be set to the animation's default (usually 1080x1920px for stories and 1920x1080px for the rest).

What is translatesAutoresizingMaskIntoConstraints in Swift?

translatesAutoresizingMaskIntoConstraints. A Boolean value that determines whether the view's autoresizing mask is translated into Auto Layout constraints.

What is a view in Swift?

Views are the fundamental building blocks of your app's user interface, and the UIView class defines the behaviors that are common to all views. A view object renders content within its bounds rectangle, and handles any interactions with that content.


1 Answers

This is the kind of thing that can be a bit complicated to figure out from docs and trial-and-error, but once you get it you'll wonder why you found it so confusing in the first place. I would:

  1. Read Handling Layout Changes Automatically Using Autoresizing Rules from the View Programming Guide.
  2. Play with the springs and struts in the Size inspector in Interface Builder. Putting a horizontal spring inside the box is equivalent to setting UIViewAutoresizingFlexibleWidth (and similarly for height). Putting a strut on top of the box is equivalent to turning UIViewAutoresizingFlexibleTopMargin off (and similarly for the bottom, left, and right margins).
like image 171
yuji Avatar answered Oct 03 '22 07:10

yuji