IOS Study Notes-UIButton, ios-uibutton

Source: Internet
Author: User

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.

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.