Autoresizingmask attribute of uiview

Source: Internet
Author: User

1. Explanation

In uiview, there is an autoresizingmask attribute, which corresponds to an enumerated value (as follows). The attribute means to automatically adjust the position between the child control and the parent control, with a width and height.

123456789 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.
Uiviewautoresizingflexibleleftmargin automatically adjusts the distance from the left side of superview to ensure that the distance from the right side of superview remains unchanged.
Uiviewautoresizingflexiblerightmargin automatically adjusts the right distance from the superview to ensure that the left distance from the superview remains unchanged.
Uiviewautoresizingflexibletopmargin automatically adjusts the distance from the superview top to ensure that the distance from the superview bottom remains unchanged.
Uiviewautoresizingflexiblebottommargin automatically adjusts the distance from the superview bottom, that is, the distance from the superview top remains unchanged.
Uiviewautoresizingflexiblewidth automatically adjusts its width to ensure the distance from the left and right sides of superview.
Uiviewautoresizingflexibleheight automatically adjusts its height to ensure the distance from the top and bottom of the superview.
Uiviewautoresizingflexibleleftmargin. For example, if the original distance is 20, 30, the adjusted distance should be 68,102, that is, 68/20 = 102/30.

Other combinations are similar.

2. Instance

Create a tableview as follows:

 _videoTable = [[UITableView alloc] initWithFrame:rect style:UITableViewStylePlain];    _videoTable.backgroundColor = [UIColor yellowColor];    _videoTable.dataSource = self;    _videoTable.delegate = self;    _videoTable.autoresizingMask = UIViewAutoresizingFlexibleHeight;//1    [self.view addSubview:_videoTable];

Compare the effect of comments and comments on code 1:

The gray part at the bottom is a view. The left-side figure shows the effect of setting the autoresizingmask attribute of the table, and no effect is set on the right.

 

3. Reference

Http://blog.csdn.net/yuquan0821/article/details/7596545

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.