Summary of methods properties for IOS common controls

Source: Internet
Author: User
Tags uicontrol word wrap

A UIVIew common attribute
1.frame position and size (in the upper-left corner of the parent control as the origin point (0,0))
2.center midpoint (in the upper-left corner of the parent control as the origin point (0,0))
3.bounds position and size (in its own upper left corner as the origin point (0,0))
4.transform Deformation properties (scaling, rotation)
5.backgroundColor background Color
6.tag identification (the parent control can find the corresponding child control based on this identity, not the same as a child control in the same parent control)
7. Hidden set Whether you want to hide
8.alpha Transparency (0~1);
9.opaque opacity (0~1);
10.userInteractionEnabled can interact with the user (YES can interact)
11.superView Parent Control
12.subviews child controls
Pattern stretching adaptive for 13.contentMode content display

[View Viewwithtag:10];
[
BTN1 9
BTN2 10
ImageView 2 10
]

Two. UIView Common methods
1.addSubview
Add child controls, added to top (last face in Subviews)

2.removeFromSuperview
Remove from parent control

3.viewWithTag:
The parent control can find the corresponding control (traversing all child controls) based on the tag identity.

4.insertsubview:atindex:
Add a child control to a specified location

5. Two ways to perform an animation with two class methods
+ (void) Beginanimations: (NSString *) Animationid context: (void *) context;
/**.. Code to perform the animation: **/
+ (void) commitanimations;

6. Performing animations with Blok
/*
Duration Animation duration
Animations storing code that requires forest to perform animations
Completion the action code to be executed after the animation is stored
*/
+ (void) Animatewithduration: (nstimeinterval) duration animations: (void (^) (void)) animations completion: (void (^)) ( BOOL finished) completion

7. Change the view layer order

-(void) removefromsuperview;//remove layer (control)

-(void) Insertsubview: (UIView *) View Atindex: (nsinteger) index;//insert layer in a location

-(void) Exchangesubviewatindex: (Nsinteger) index1 Withsubviewatindex: (nsinteger) index2;//swap layers from two different locations

-(void) Addsubview: (UIView *) view;//add layer on top

-(void) Insertsubview: (UIView *) View Belowsubview: (UIView *) siblingsubview;//insert a layer underneath a layer (a layer must be his brother view, That must be on a parent view)

-(void) Insertsubview: (UIView *) View Abovesubview: (UIView *) siblingsubview;//insert a layer above one layer (IBID.)

-(void) Bringsubviewtofront: (UIView *) view;//a control is referred to the top

-(void) Sendsubviewtoback: (UIView *) view;//a control is referred to the bottom

/*

The following two are typical protocol methods, and you can customize the class to rewrite their method body. When the control performs the appropriate action, let it execute.

*/

-(void) Didaddsubview: (UIView *) subview;//has added this control to call this method

-(void) Willremovesubview: (UIView *) subview;//is about to remove this control call this method


Three. Uicontrol
1. As long as you inherit Uicontrol, you can simply handle the event (click event, Value Change event)

2. Inherits the subclass of the Uicontrol
UIButton.UISlider.UISwitch.UIDatePicker, wait.

3. When you need to listen for a child control time, the steps to resolve:

1>: First see if it inherits from Uicontrol
2> see if it has a delegate property inside it.

4. Common Properties

1>enabled can handle time
2>contentverticalalignment how content is arranged in the vertical direction
3>contenthorizontalalignment how content is arranged in a horizontal direction
5. Common methods
1> Adding listeners
/*
Target Listener Object
The method that is called when the action event fires, and the method that invokes the target
*/
-(void) AddTarget: (ID) Target action: (SEL) Action forcontrolevents: (uicontrolevents) controlevents;

2> Deleting listeners
When the listener is deleted, the listener is no longer notified when the event fires, and the target's action method is no longer called.
-(void Roemovetarget: (ID) Target action:] (SEL) Action forcontrolevents:] (uicontrolevents) controlevents);

3> Get all Listener objects
-(Nsset *) alltargets;

Four, UILabel
1. Common Properties
1>text the text content that is displayed
2>textcolor text color
3> Font Fonts
4> shadow Color of shadowcolor text
5> Shadowoffset Shadow deviation distance (width horizontal deviation distance, height vertical direction distance, positive bottom)
6> TextAlignment Set the text arrangement method (left, right, center).
7>numberoflines allows text to have a maximum number of lines (if 0, word wrap).
Five. UIButton
//. UISlider. Uiswitch. Uidatepicker, wait.

(1) The UISlider slider control is commonly used in iOS development to adjust UI interactions such as volume, font size, and the usage summary is as follows:

Initialize a slider:

?
1  UISlider * slider = [[UISlider alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];

Set the position of the slider

@property (nonatomic) float value;
This value is between the maximum and minimum values of the slider, and if no boundary value is set, the default is 0-1;

Set the slider minimum boundary value (default = 0)

@property (nonatomic) float MinimumValue;

Set slider maximum boundary value (default = 1)

@property (nonatomic) float MaximumValue;

Set the picture that appears at the leftmost end of the slider:

@property (Nonatomic,retain) UIImage *minimumvalueimage;

Set the picture that appears at the right end of the slider:

@property (Nonatomic,retain) UIImage *maximumvalueimage;

Sets whether the slider value changes continuously (default = yes)

@property (nonatomic,getter=iscontinuous) BOOL continuous;

When this property is set to Yes, its value changes at any time and is set to no when it is sliding, and value changes when the swipe ends.

Sets the color of the left (less than part) line of the slider

@property (Nonatomic,retain) Uicolor *minimumtracktintcolor;

Set the color of the line to the right (greater than part) of the slider

@property (Nonatomic,retain) Uicolor *maximumtracktintcolor;

Set the slider color (affects colors that have crossed one end)

@property (Nonatomic,retain) Uicolor *thumbtintcolor;

Note This property: If you do not set the slider of the picture, that this property will only change the color has been across a line, will not change the color of the slider, if you set the slider picture, and set this property, then the slider picture will not display, the color of the slider will change (IOS7)

To manually set the value of the slider:

-(void) SetValue: (float) value animated: (BOOL) animated;

To set the picture for the slider:

-(void) Setthumbimage: (UIImage *) image forstate: (uicontrolstate) state;

Set the line pattern across a section of the slider

-(void) Setminimumtrackimage: (UIImage *) image forstate: (uicontrolstate) state;

Set the line pattern that the slider does not slide across the section

-(void) Setmaximumtrackimage: (UIImage *) image forstate: (uicontrolstate) state;

Several of the corresponding Get methods

-(UIImage *) Thumbimageforstate: (uicontrolstate) state;
-(UIImage *) Minimumtrackimageforstate: (uicontrolstate) state;
-(UIImage *) Maximumtrackimageforstate: (uicontrolstate) state;

Corresponding method for setting the response property of the current state

@property (nonatomic,readonly) uiimage* currentthumbimage;
@property (nonatomic,readonly) uiimage* currentminimumtrackimage;
@property (nonatomic,readonly) uiimage* currentmaximumtrackimage;

To add a trigger event

?
1 [slider addTarget:self action:@selector(log:) forControlEvents:UIControlEventValueChanged];

(2) Uiswitch Simple Use Summary:

Initialize: When the control is named, be careful not to use the keyword, switch. Otherwise, there is an issue that cannot be initialized.

-(Instancetype) initWithFrame: (CGRect) frame;

This frame is meaningless, and the size of the system's switch control is deterministic.

To set the color of the switch when the state is turned on

@property (nonatomic, retain) Uicolor *ontintcolor;

Set Switch style color

@property (nonatomic, retain) Uicolor *tintcolor;

Set the switch button color

@property (nonatomic, retain) Uicolor *thumbtintcolor;

Set the picture when the switch is on (note: no longer works after IOS7)

@property (nonatomic, retain) UIImage *onimage;

Set the picture when the switch is off (note: No longer works after IOS7)

@property (nonatomic, retain) UIImage *offimage;

Status of the switch

@property (Nonatomic,getter=ison) BOOL on;

Manually set the switch status

-(void) SetOn: (BOOL) on animated: (BOOL) animated;

A little bit of a feeling: The iOS system's Uiswitch control, although very poor in customization, with the IOS7 of the flat and frugal style, in beauty is really not inferior to any private custom switch control, in the absence of special needs, for switching logic, this is a very good UI interaction choice.

(3) Uidatepicker

Uipickerview is a native selector control in iOS that is easy to use, simple in usage, and beautifully effective. The data source proxy must be set, and no data source methods are executed to datepicker the number of rows and columns. The control is not displayed and crashes.

@property (nonatomic,assign) id<uipickerviewdatasource> DataSource;

@property (nonatomic,assign) id<uipickerviewdelegate> delegate;

Set up data sources and proxies

@property (nonatomic) BOOL showsselectionindicator;

Whether the selection box is displayed, this property has no effect after iOS7

@property (nonatomic,readonly) Nsinteger numberofcomponents;

Get the number of partitions

-(Nsinteger) Numberofrowsincomponent: (Nsinteger) component;

Gets the number of rows for a partition

-(Cgsize) Rowsizeforcomponent: (Nsinteger) component;

Get the dimensions of a partition row

-(UIView *) Viewforrow: (Nsinteger) Row forcomponent: (Nsinteger) component;

Get a view of a row in a partition

-(void) reloadallcomponents;

Reload All partitions

-(void) Reloadcomponent: (Nsinteger) component;

Overloading a partition

-(void) SelectRow: (Nsinteger) Row incomponent: (Nsinteger) component animated: (BOOL) animated;

Set a row to select a partition

-(Nsinteger) Selectedrowincomponent: (Nsinteger) component;

Returns a selected row of a partition

Methods in the data source proxy:

-(Nsinteger) Numberofcomponentsinpickerview: (Uipickerview *) Pickerview;

Set Number of partitions

-(Nsinteger) Pickerview: (Uipickerview *) Pickerview numberofrowsincomponent: (nsinteger) component;

Set the number of rows by partition

Methods in the proxy:

-(CGFloat) Pickerview: (Uipickerview *) Pickerview widthforcomponent: (nsinteger) component;

Set the partition width

-(CGFloat) Pickerview: (Uipickerview *) Pickerview rowheightforcomponent: (nsinteger) component;

Set Partition Row Height

-(NSString *) Pickerview: (Uipickerview *) Pickerview Titleforrow: (nsinteger) Row forcomponent: (Nsinteger) component;

Set the caption displayed for a row

-(Nsattributedstring *) Pickerview: (Uipickerview *) Pickerview Attributedtitleforrow: (nsinteger) row forComponent: ( Nsinteger) component;

To set the caption displayed by a row through a property string

-(UIView *) Pickerview: (Uipickerview *) Pickerview Viewforrow: (nsinteger) Row forcomponent: (Nsinteger) component Reusingview: (UIView *) view;

Set the view view displayed for a row

-(void) Pickerview: (Uipickerview *) Pickerview Didselectrow: (nsinteger) Row incomponent: (Nsinteger) component;

Callback that is executed when a row is selected


1. Common Properties

1>titlelabel gets the internal Uilabel object
2>imageview gets the internal Uiimageview object

2. Common methods
1> setting the text content of the internal Uilabel display
When you set the button text, you cannot btn. Titlelabel.text = @ "4324324";
-(void) Settitle: (NSString *) title forstate: (uicontrolstate) state; Default is nil. Title is assumed

2> set the text color of the internal Uilabel
-(void) Settitlecolor: (Uicolor *) color forstate: (uicontrolstate) state ui_appearance_selector; Default if nil. Use opaque white
3> Set the text shadow color of the inner Uilabel
-(void) Settitleshadowcolor: (Uicolor *) color forstate: (uicontrolstate) state ui_appearance_selector; Default is nil. Use 50% Black
4> setting a picture of an internal uiimageview
-(void) SetImage: (UIImage *) image forstate: (uicontrolstate) state; Default is nil. Should is same size if different for different states
5> setting a picture of an internal uiimageview
-(void) SetBackgroundImage: (UIImage *) image forstate: (uicontrolstate) state ui_appearance_selector; Default is Nil

6> The following two methods need to be handed over to subclasses to rewrite
Returns the frame (position and size) of the internal Uilabel
-(CGRect) Titlerectforcontentrect: (CGRect) Contentrect;
Returns the size and position of the internal uiimage
-(CGRect) Imagerectforcontentrect: (CGRect) Contentrect;

7> The following methods can get some properties in different states
-(NSString *) Titleforstate: (uicontrolstate) state; These getters only take a single state value
-(Uicolor *) Titlecolorforstate: (uicontrolstate) state;
-(Uicolor *) Titleshadowcolorforstate: (uicontrolstate) state;
-(UIImage *) Imageforstate: (uicontrolstate) state;
-(UIImage *) Backgroundimageforstate: (uicontrolstate) state;
-(Nsattributedstring *) Attributedtitleforstate: (uicontrolstate) state Ns_available_ios (6_0);

Summary of methods properties for IOS common controls

Related Article

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.