An instance UIButton of the class implements a button on the touch screen. A button intercepts touch events and sends an action message to a target object when tapped. Methods for setting the target and action is inherited UIControl from. This class provides methods for setting the title, image, and other appearance properties of a button. By using the these accessors, you can specify a different appearance for each button state. (iOS official documentation explained)
Creating Buttons
Class method: Buttonwithtype:
+ (ID)buttonwithtype: (uibuttontype) buttonType
Parameters:
typedef enum {
Uibuttontypecustom = 0,--no button style
Uibuttontypesystem,--a System Style button, such as those shown in navigation bars and toolbars (Av Ailable in IOS 7.0 and later).
uibuttontypedetaildisclosure,--a Detail disclosure button
uibuttontypeinfolight,--an information button that had a light background
Uibuttontypeinfodark,--an information button that has a dark background
< Span class= "p" > uibuttontypecontactadd, --a Contact Add button
< Span class= "p" > uibuttontyperoundedrect , --a rounded-rectangle Style button
} uibuttontype;
Configuring the Button Title
Properties: Titlelabel:
@property(nonatomic, readonly, retain) UILabel *Titlelabel
A view that displays the value currentTitle of the property for a button. (read-only)
Use it own properties primarliy to configure the text of the button.
Use the settitlecolor:forstate: and settitleshadowcolor:forstate: mothods of this class to make tho SE changes.
Properties: Currenttitle:
@property(nonatomic, readonly, retain) nsstring *currenttitle
The value is set automatically whenever the button state changes.
Titleforstate:
Returns the title associated with the specified state.
-(NSString *)titleforstate: (uicontrolstate) state
Parameters:UIControlState
Method:-Settitle:forstate:
Sets the title of the specified state.
-(void)Settitle: (nsstring *) title
forstate: (uicontrolstate) state
Method: Attributedtitleforstate:
Method: Setattributedtitle:forstate
Method: Titlecolorforstate:
Method: Settitlecolor:forstate:
Method: Titleshadowcolorforstate:
Method: Settitleshadowcolor:forstate:
Properties: reversestitleshadowwhenhighlighted:
Document Link: Https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIButton_Class/index.html#//apple_ ref/doc/uid/tp40006815
Resources:
View ProgrammingGuide for IOS.
Buttons.
iOS Learning Note-uibutton