iOS Learning Note-uibutton

Source: Internet
Author: User

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

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.