04-Common Properties of controls

Source: Internet
Author: User

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:
    1. Update download progress in real time during file download

    1. 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.
    1. Each UI control is an object
    2. Modifying the state of a UI control is actually modifying the properties of a control object
    3. For example, if you modify the text displayed by Uilabel, modify the Text property of the Uilabel object to
    4. 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:
    1. Uiprogressview progress bar control has progress property (progress value)

    2. Uilabel and Uitextfield all have text properties (display text)

    3. ... ...

    • 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:
    1. Frame: Position and size

    2. Center: Central Point Location

    3. ... ...

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) nsinteger tag;

    • The id\ ID of the control that the parent control can use to locate the corresponding child control

    • @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
    1. -(void) Addsubview: (UIView *) view;
    2. Add a child control view

    1. -(void) Removefromsuperview;
    2. Remove from parent control

    1. -(UIView *) Viewwithtag: (nsinteger) tag;
    2. Find the corresponding control based on a tag ID (usually a child control)

04-Common Properties of controls

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.