Briefly describe the properties and usage of uiview

Source: Internet
Author: User
1. Alpha

Sets the view transparency. The default value is 1.

// Completely transparent

View. Alpha = 0;

// Not transparent

View. Alpha = 1;

2. clipstobounds

// The default value is no. When it is set to yes, the content beyond the current view size and the subview will not be displayed.

View. clipstobounds = yes;

3. Hidden

// The default value is no. If it is set to yes, the view will be invisible.

View. Hidden = yes;

 

4. userinteractionenabled

// The default value is yes. If it is set to no, the view cannot interact with the user. (Cannot respond to events)

View. userinteractionenabled = no;

5. Tag

// The default value is 0, which is used to mark

View. Tag = 0;

5. exclusivetouch

The default value is no.

Exclusivetouch indicates that if the uiview with exclusivetouch set is the first responder of the entire touch event, other uiviews before all your fingers exit the screen will not be able to accept all touch events throughout the event cycle.

6. cgrect Frame

1> indicates the position and size of the control (with the upper left corner of the parent control as the coordinate origin (0, 0 ))

2> modify this property to adjust the widget's position and size.

 

7. cgpoint Center

1> indicates the midpoint of the control (with the upper left corner of the parent control as the coordinate origin)

2> modify this property to adjust the widget location

 

8. cgrect Bounds

1> indicates the position and size of the control (with the coordinates of the origin in the upper left corner of the control, the position is always (0, 0 ))

2> to modify this attribute, you can only adjust the widget size.

 

9. cgaffinetransform Transform

1> represents the control's deformation status (rotation angle, scaling ratio)

2> Create a cgaffinetransform Function

* Cgaffinetransformmakescale (cgfloat Sx, cgfloat SY)

Create a scaling ratio in the X and Y directions to be the deformation values of SX and SY, respectively.

 

* Cgaffinetransformmakerotation (cgfloat angle)

Create a deformation value with the rotation angle of Angle

 

* Cgaffinetransformscale (cgaffinetransform T, cgfloat Sx, cgfloat SY)

Based on the deformation value T, scale again. The scaling ratios in the X and Y directions are SX and SY respectively, and then return a new deformation value.

 

* Cgaffinetransformrotate (cgaffinetransform T, cgfloat angle)

Based on the deformation value T, the rotation is performed, the rotation angle is angle, and a new deformation value is returned.

10. superview

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

11. Window

Return to the current view window. (Window)

 

When obtaining superview and window of the Root View, you must note that viewdidload cannot be obtained. viewdidload is only the view Load completed and is not added to the window, therefore, you must obtain the value in the viewdidappear method. Then the view is 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 value is yes, indicating that when the size of the parent view changes, the Child view also changes.

13. autoresizingmask

The default value is uiviewautoresizingnone, which is not automatically scaled.

14. contentmode

Set the content mode.

Uiviewcontentmodescaletofill is not filled in any proportion according to the original width proportion (length and width increase. In this way, the view will not be blank and all content can be displayed.

Uiviewcontentmodeaspecttofill is filled according to the ratio of original length to width, not all contents are displayed completely. In this way, the content may overflow, but the entire view will not be left blank.

Uiviewcontentmodeaspecttofit displays all content in accordance with the original length/width ratio (length/width ratio. In this way, the left and right sides are easily left blank or left blank.

15. backgroundcolor

The default value is nil.

// Set the background color to red.

Self. View. backgroundcolor = [uicolor redcolor];

16. How to add a subview to a uiview
  1. Addsubview: // Add a view to a view
  2. Bringsubviewtofront: // move a View to the front
  3. Sendsubviewtoback: // push a View to the back
  4. Removefromsuperview // remove the view
  5. Insertsubview: atindex: // insert a view and specify an index
  6. Insertsubview: abovesubview: // insert a view above a view
  7. Insertsubview: belowsubview: // insert a view under a view
  8. Exchangesubviewatindex: withsubviewatindex: // exchange views of Two-position Indexes

Briefly describe the properties and usage of uiview

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.