UIView some basic properties

Source: Internet
Author: User

UIView Property 1.alpha

Sets the transparency of the view. Default is 1.

Fully Transparent

View.alpha = 0;

Not transparent

View.alpha = 1;

2.clipsToBounds

The default is no, and when set to Yes, content and child views that exceed the dimensions of the current view are not displayed.

View.clipstobounds = YES;

3.hidden

The default is no, and when set to Yes, the view is not visible.

View.hidden = YES;

4.userInteractionEnabled

The default is yes, and if set to No,view, you cannot interact with the user. (That is, you cannot respond to events)

view.userinteractionenabled = NO;

5. Tag

The default is 0, which is used to mark the view's

View.tag = 0;

5. Exclusivetouch

Default is No

The point of Exclusivetouch is that if the current set of Exclusivetouch UIView is the first responder of the entire touch event, then all of your fingers leave the screen before the other UIView is unable to accept all the touch events during the entire event cycle.

6.CGRect Frame

1> represents the position and dimensions of the control (in the upper-left corner of the parent control as the coordinate origin (0, 0))

2> Modify this property to adjust the position and size of the control

7.CGPoint Center

1> represents the midpoint of the control (the origin of the coordinates in the upper-left corner of the parent control)

2> Modify this property, you can adjust the position of the control

8.CGRect bounds

1> represents the position and size of the control (in its own upper-left corner of the coordinates origin, where the position is always (0, 0))

2> Modify this property to adjust the size of the control only

9.CGAffineTransform Transform

1> represents the deformation state of the control (rotation angle, scale)

2> Creating a Cgaffinetransform function

* Cgaffinetransformmakescale (cgfloat sx, CGFloat Sy)

Creates an X, Y-direction scaling ratio of SX, SY, respectively

* Cgaffinetransformmakerotation (cgfloat angle)

Creates a deformation value that rotates at an angle of angle

* Cgaffinetransformscale (Cgaffinetransform t, cgfloat SX, CGFloat Sy)

On the basis of the deformation value T, then Zoom, the x, y direction of the scaling ratio is SX, SY, and then return a new deformation value

* Cgaffinetransformrotate (Cgaffinetransform t, cgfloat angle)

On the basis of the deformation value T, the rotation angle is angle, and then a new deformation value is returned.

10.superview

Returns the parent view of the current view. (Read only)

11.window

Returns the window of the current view. Window

When getting the Superview and window of the root view, it is important to note that it is not available in Viewdidload, viewdidload only the view load is complete and is not added to the window, so it needs to be acquired in the Viewdidappear method. The view was then added to the window.

-(void) viewdidload

{

[Super Viewdidload];

NSLog (@ "%@", Self.view.superview); No value

NSLog (@ "%@", Self.view.window); No value

}

-(void) Viewdidappear: (BOOL) animated

{

NSLog (@ "%@", Self.view.superview); has a value

NSLog (@ "%@", Self.view.window); has a value

}

12.autoresizesSubviews

The default is yes, which means that when the parent view size changes, the child view changes as well.

13.autoresizingMask

The default is Uiviewautoresizingnone and does not scale automatically.

14.contentMode

Sets the content mode.

The Uiviewcontentmodescaletofill is not populated at any scale according to the original width-to-height ratio (long and wide unequal scales). This way, the view is not blank and the content can be displayed all.

The Uiviewcontentmodeaspecttofill is filled with the original length-width ratio and does not fully display the entire content. This may overflow, but the entire view will not leave a blank space.

The Uiviewcontentmodeaspecttofit is fully displayed in terms of the original length-width ratio (growth in length and width). This makes it easy to photograph or leave a blank.

15.backgroundColor

The default is nil.

Set the background color to red

Self.view.backgroundColor = [Uicolor Redcolor];

16.UIView common ways to add a child view
    1. Add a view to a view
    2. Addsubview:
    3. Move a view to the front
    4. Bringsubviewtofront:
    5. Push a view to the back
    6. Sendsubviewtoback:
    7. To remove a view
    8. Removefromsuperview
    9. Insert a view and specify an index

10.insertsubview:atindex:

11.//Insert View above a view

12.insertsubview:abovesubview:

13.//Insert view under a view

14.insertsubview:belowsubview:

15.//swapping views of two-position indexes

16.exchangesubviewatindex:withsubviewatindex:

UIView some basic properties

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.