IOS學習筆記-UIButton,ios-uibutton

來源:互聯網
上載者:User

IOS學習筆記-UIButton,ios-uibutton

UIButton 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 are inherited from UIControl. 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官方文檔解釋)

Creating Buttons


類方法:buttonWithType:

+ (id)buttonWithType:(UIButtonType)buttonType

參數:

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;

 

Configuring the Button Title

屬性:titleLabel:

@property(nonatomic, readonly, retain) UILabel *titleLabel

A view that displays the value of the currentTitle property 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.

 

屬性: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

參數: UIControlState

 

方法:- setTitle:forState:

Sets the title to use for the specified state.

- (void)setTitle:(NSString *)title
        forState:(UIControlState)state

 

方法:attributedTitleForState:

 

方法:setAttributedTitle:forState

 

方法:titleColorForState:

 

方法: setTitleColor:forState:

 

方法:titleShadowColorForState:

 

方法:setTitleShadowColor:forState:

 

屬性:reversesTitleShadowWhenHighlighted:

 

 

Configuring Button Presentation

屬性:adjustsImageWhenHighlighted

A Boolean value that determines whether the image changes when the button is highlighted.

@property(nonatomic) BOOL adjustsImageWhenHighlighted

 

屬性:adjustsImageWhenDisabled

A Boolean value that determines whether the image changes when the button is disabled.

@property(nonatomic) BOOL adjustsImageWhenDisabled

 

屬性:showsTouchWhenHighlighted

A Boolean value that determines whether tapping the button causes it to glow.

@property(nonatomic) BOOL showsTouchWhenHighlighted

 

backgroundImageForState

 

imageForState:

 

setBackgroundImage:forState:

 

setImage:forState:

 

屬性:tintColor 

 

文檔連結:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIButton_Class/index.html#//apple_ref/doc/uid/TP40006815

參考資料:

 View Programming Guide for iOS.

 Buttons.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.