UI controls
What is a control?
– All UI elements on the screen are called controls (also called views, components)
– such as buttons (UIButton), text (UILabel) are controls
What are the common properties of a control?
– Dimensions
– Location
– Background color
– ......
Apple extracts the common properties of the control into the parent class UIView
All controls eventually inherit from UIView.
UIButton, Uilabel both inherit from UIView (can view header file validation)
UI controls that may be used
–uibutton button
–uilabel Text Labels
–uitextfield Text Input Box
–uiimageview Picture Display
–uiscrollview scrolling Controls
–uitableview form
–uicollectionview Nine Gongge
–uiwebview Web page display controls
–uialertview dialog box (Middle Bullet box)
–uinavigationbar Navigation Bar
–uipagecontrol Pagination Control
–uitextview text display controls that can be scrolled
–uiactivityindicator Circle
–uiswitch switch
–uiactionsheet Bottom Bullet Frame
–uidatepicker Date Selector
–uitoolbar Tool Bar
–uiprogressview progress bar
–uislider Sliding block
–uisegmentcontrol tab
–uipickerview Selector
UIView
- The purest, cleanest control with basic properties such as size, position, background color, etc.
uilabel-Text Labels
- Picture controls, with picture properties
- Basic properties such as size, position, background color, etc.
- The function is to display a string of fixed text
UIButton
- The role of the button is: Listen to the user's click events, after the user clicks to respond
uitextfield-Text Input Box
- Text input box pops up the keyboard to let users enter text content
uitextview-text display controls that can be scrolled
- If the text content is more, you need to change the line display, and you need to edit
Uiimageview
- Text control, with text, text color properties
- Basic properties such as size, position, background color, etc.
uiprocessview-progress bar
- Horizontal progress bar, such as showing the download progress of the file, the program's Start progress
uislider-Sliding block
- Swipe between 2 values, such as adjusting the volume
uiactivityindicator– Circle
- has been spinning around, indicating that the user waits for
uialertview– dialog box (Middle Bullet box)
- Jump out a box in the middle to prompt the user what to do next
uiactionsheet– Bottom Bullet Frame
- Jump from the bottom of a box and prompt the user what to do next
uiscrollview– scrolling Controls
- If the content is more than one screen, you can use it to display
uipagecontrol– Pagination Control
- Ability to display pagination view page numbers (mostly scrolling small dots)
uitableview– form
- Use this table control if the contents of each row are displayed in a similar format
uicollectionview– Nine Gongge
- If the display is a piece, a lattice, and each lattice is about the same length, you can use it
uiwebview– Web page display controls
- Commonly used to display Web pages, use it, you can browse the Web on the phone
uiswitch– switch
- Either open or close (mostly green and white)
uisegmentcontrol– tab
- Choose between several fixed options
uipickerview– Selector
- Select only one row between multiple rows of data
uidatepicker– Date Selector
uitoolbar– Tool Bar
- Typically displayed at the bottom or top of the keyboard with a few small buttons
uinavigationbar– Navigation Bar
- The bar displayed at the top
Parent control, child control
Each control is a container that can hold other controls
Inner Gizmo is a child of a large control
The large control is the parent control of the inner gizmo
There is a default UIView property within each controller (Uiviewcontroller)
– @property (Nonatomic,retain) UIView *view;
– All other controls managed in the controller are child controls of this view (direct or indirect)
UIView Common Properties
@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 (identity) of the control, and the parent control can find the corresponding child control via tag
@property (nonatomic) Cgaffinetransform transform;
– The deformation properties of the control (you can set the rotation angle, scale, pan, and so on)
-(void) Addsubview: (UIView *) view;
– Add a child control view
-(void) Removefromsuperview;
– Remove from parent control
-(UIView *) Viewwithtag: (nsinteger) tag;
– Find the corresponding control (usually child controls) based on a tag identifier
@property (nonatomic) cgrect frame;
– The position and dimensions of the control 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 dimensions of the control rectangle (the origin of the coordinates in its upper-left corner, so bounds X, Y is generally 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.
Simple UI Summary