IOS Study Notes-UIButton, ios-uibutton
UIButtonClass 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 are inherited fromUIControl. This class provides methods for setting the title, image, and other appearance properties of a button. by using these accessors, you can specify a different appearance for each button state. (ios official documentation)
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 (Available in iOS 7.0 and later ).
UIButtonTypeDetailDisclosure, -- A detail disclosure button
UIButtonTypeInfoLight, -- An information button that has a light background
UIButtonTypeInfoDark, -- An information button that has a dark background
UIButtonTypeContactAdd, -- A contact add button
UIButtonTypeRoundedRect, -- A rounded-rectangle style button
} UIButtonType;
Refreshing the Button Title
Attribute: titleLabel:
@ Property (nonatomic, readonly, retain) UILabel * titleLabel
A view that displays the value ofcurrentTitleProperty for a button. (read-only)
Use its own properties primarliy to configure the text of the button.
Use the setTitleColor: forState: and setTitleShadowColor: forState: mothods of this class to make those changes.
Property: currentTitle:
@ Property (nonatomic, readonly, retain) NSString * currentTitle
The value for this property 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 to use for 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:
Property: reversesTitleShadowWhenHighlighted:
Processing Button Presentation
Attribute: adjustsImageWhenHighlighted
A Boolean value that determines whether the image changes when the button is highlighted.
@ Property (nonatomic) BOOL adjustsImageWhenHighlighted
Property: adjustsImageWhenDisabled
A Boolean value that determines whether the image changes when the button is disabled.
@ Property (nonatomic) BOOL adjustsImageWhenDisabled
Property: showsTouchWhenHighlighted
A Boolean value that determines whether tapping the button causes it to glow.
@ Property (nonatomic) BOOL showsTouchWhenHighlighted
BackgroundImageForState
ImageForState:
SetBackgroundImage: forState:
SetImage: forState:
Attribute: tintColor
Link: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIButton_Class/index.html#//apple_ref/doc/uid/TP40006815
References:
View Programming Guide for iOS.
Buttons.