1.UIButton Status:
UIControlStateNormal//Normal status
uicontrolstatehighlighted//Highlight Status
uicontrolstatedisabled//Disable status
uicontrolstateselected//Check Status
Uicontrolstateapplication//
uicontrolstatereserved//Reserved status
2.Uibutton Type:
Uibuttontypecustom//Custom type
Uibuttontyperoundedrect//Fillet type
Uibuttontypedetaildisclosure//Detail Display button
Uibuttontypeinfolight//Light Background Info button
Uibuttontypeinfodark//Dark Background information button
Uibuttontypecontactadd//Add button
3.UIButton Common Properties
When you set text to a button, the Apple document describes that you cannot use a Label object to set the color or shadow color of the text, but instead you must use the
SetTitleColor:forState:and Settitleshadowcolor:forstate: These two methods can modify these values.
Set other properties in the button and so on ....
Sets the caption content of the corresponding state to default is nil. Title is assumed-be-line-(void) Settitle: (NSString *) title forstate: (uicontrolstate) state; Sets the caption color for the corresponding status -(void) Settitlecolor: (Uicolor *) color forstate: (uicontrolstate) state; Sets the caption shadow color for the corresponding status -(void) Settitleshadowcolor: (Uicolor *) color forstate: (uicontrolstate) state; Picture of the button that sets the corresponding status-(void) SetImage: (UIImage *) image forstate: (uicontrolstate) state;
Add Event
-(void) AddTarget: (ID) Target action: (SEL) Action forcontrolevents: (uicontrolevents) controlevents;
These events are touch-based, value-based, and edit-based. The following events are triggered.
When the button is clicked, the button is concave, then the event is triggered, and the state of the button is:
Uicontroleventtouchdown //Press uicontroleventtouchdownrepeat multiple times Press uicontroleventtouchupinside// Loosen the uicontroleventtouchupoutside//button outside the button and its certain periphery
4.adjustsImageWhenDisabled
When the button is disabled, the color of the image is drawn darker and the default is yes.
5.adjustsImageWhenHighlighted
When the button is highlighted, the color of the image is drawn darker and the default is yes.
6.showsTouchWhenHighlighted
Button.showstouchwhenhighlighted=yes; When clicked, the flash effect is obscured by the foreground image.
6.contentEdgeInsets
Sets the internal content of the button, including the button picture and caption, from the top or bottom of the button edge.
7. Button instance
1. Sometimes we want the title of UIButton to be left aligned, we set
Btn.textlabel.textalignment= Uitextalignmentleft
is not useful, we need to set
Btn.contenthorizontalalignment = Uicontrolcontenthorizonalignmentleft;
But the problem comes out again, when the text is pressed to the left border, we can set
Btn.contentedgeinsets = Uiedgeinsetsmake (0,10, 0, 0);
Keeps the text distance from the left border by 10 pixels.
iOS button Common Properties