Details on common properties of UIView and details of uiview

Source: Internet
Author: User

Details on common properties of UIView and details of uiview

The previous section describes some common attributes of a space. This section describes the common attributes of a UIVIew.

First, introduce the common attributes of the UIView described in the previous article:

// Position and size of the rectangle of the control in the parent control (with the coordinate origin in the upper left corner of the parent Control) @ property (nonatomic) CGRect frame; // The position and size of the rectangle where the control is located (the coordinate origin is in the upper left corner of the control, so the x \ y of bounds is usually 0) @ property (nonatomic) CGRect bounds; // The position of the control's midpoint (with the upper left corner of the parent control as the coordinate origin) @ property (nonatomic) CGPoint center; // control deformation attributes (you can set attributes such as rotation angle, proportional scaling, and translation) @ property (nonatomic) CGAffineTransform transform;

To learn about these common attributes, you must first know that in UIKit, the origin () of the coordinate system is in the upper left corner, the x value is in the forward direction to the right, and the y value is in the forward direction, as shown in

@ Property (nonatomic) CGRect frame;
struct CGRect {   CGPoint origin;   CGSize size;};typedef struct CGRect CGRect;

CGRect is a struct with the origin and size attributes. The origin is a CGPoint and a vertex. It has two attributes X/Y, representing the position.

Size is a CGSize, which has two attributes: Width/Height, representing the Width and Height.

The frame attribute describes the position and size of the current view in the parent view.

Therefore, the reference point of the frame attribute of the button is the parent view (newly added view), with the coordinate origin in the upper left corner of the parent view.

@ Property (nonatomic) CGRect bounds;

The main difference between the frame and the position and size of the rectangle frame where the control is located (the coordinate origin is in the upper left corner of the control, so the x \ y of bounds is generally 0) is also true.


@ Property (nonatomic) CGPoint center;

Control Point Position (with the upper left corner of the parent control as the coordinate origin): A CGPoint with only the x/y attribute.

 


@ Property (nonatomic) CGAffineTransform transform;

Control deformation attributes (you can set attributes such as rotation angle, proportional scaling, and translation)

 

 

Summary:
  • You can use frame \ center \ transform to modify the widget's position.
  • You can use frame \ bounds \ transform to modify the widget size.
  •  

    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.