Control's Common properties modify control state
- In the process of running the program, we often have to modify (update) the display state of the UI control, such as:
- Update download progress in real time during file download
- Update playback progress in real time during music playback
How to modify control state
- Visible, you do need to modify the control state frequently
- So how do you change the state of a control? The method is simple.
- Each UI control is an object
- Modifying the state of a UI control is actually modifying the properties of a control object
- For example, if you modify the text displayed by Uilabel, modify the Text property of the Uilabel object to
- For example, if you modify the image displayed by Uiimageview, you can modify the Image property of the Uiimageview object.
- It's not hard to think that every UI control must have many properties, such as:
Uiprogressview progress bar control has progress property (progress value)
Uilabel and Uitextfield all have text properties (display text)
... ...
- Although each UI control has its own unique properties, some properties are available for each UI control, such as every UI control has its own location and size, and has its own parent control, child controls. As a result, all UI controls eventually inherit from the public properties of the Uiview,ui control defined in UIView, such as:
Frame: Position and size
Center: Central Point Location
... ...
Common Properties of UIView
- @property (nonatomic,readonly) UIView *superview;
- Get your own parent control object
- @property (nonatomic,readonly,copy) Nsarray *subviews;
- Get all of your child control objects
@property (nonatomic) Cgaffinetransform transform;
The deformation properties of the control (you can set the rotation angle, scale, pan, and other properties)
- @property (nonatomic) cgrect frame;
- Position and dimensions of the control's rectangle in the parent control (the origin of the coordinates in the upper-left corner of the parent control)
- @property (nonatomic) cgrect bounds;
- The position and size of the rectangle where the control is located (the origin of the coordinates in its upper-left corner, so the bounds x\y is typically 0)
- @property (nonatomic) Cgpoint Center;
- The position of the midpoint of the control, in the upper-left corner of the parent control, as the coordinate origin.
Uikit coordinate system
- In Uikit, the origin of the coordinate system (0,0) is in the upper-left corner, the X-value extends to the right, and the Y-value is extended forward.
Common methods of UIView
- -(void) Addsubview: (UIView *) view;
- Add a child control view
- -(void) Removefromsuperview;
- Remove from parent control
- -(UIView *) Viewwithtag: (nsinteger) tag;
- Find the corresponding control based on a tag ID (usually a child control)
04-Common Properties of controls