The original address is as follows, thank the original author! Recommend the original address to read! I wrote a little bit of my experience on his basis.
Http://www.cnblogs.com/jiangyazhou/archive/2012/06/26/2563041.html
There is a Autoresizingmask property in UIView, which corresponds to the value of an enumeration (as follows), which means that the position of the child control and the parent control is automatically adjusted to a height of width.
enum
{
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
Uiviewautoresizingnone is not automatically adjusted.
Uiviewautoresizingflexible The distance to the right is constant .
Uiviewautoresizingflexible. The
Uiviewautoresizingflexibletopmargin automatically adjusts the distance from the top of the Superview to ensure that the distance from the bottom of the Superview is constant. The
Uiviewautoresizingflexiblebottommargin automatically adjusts the distance from the bottom of the Superview, that is, the distance from the top of the Superview is unchanged.
Uiviewautoresizingflexiblewidth automatically adjusts its own width to ensure that the Superview.
Uiviewautoresizingflexibleheight automatically adjusts its height to ensure that it is Superview.
uiviewautoresizingflexibleleftmargin | Uiviewautoresizingflexiblerightmargin automatically adjusts the distance to the left of the superview to ensure that the distance to the left and to the right is the same as the distance from the left and right. For example, the original distance is 20, 30, the adjusted distance should be 68,102, that is, 68/20=102/30.
The last one needs attention. There are many changes that are derived from this rule.
In addition, although the number of variables here is similar to the settings in Xib, the Xib setting does not correspond to the variable one by one here. For example, the following code is the corresponding:
Self.testBtn.autoresizingMask = Uiviewautoresizingflexiblewidth;
This is also a problem that bothers me for a long time! Xib Select 3, you only need to set one in the code! So don't assume that the wrong code constraints are written according to the settings in the Xib!
Autoresizingmask in iOS (reproduced)