IOS学习笔记-UIButton

王朝学院·作者佚名  2016-08-27
窄屏简体版  字體: 小  |  中  |  大  |  超大  

An instance of the 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 actionare inherited from UIControl. This classPRovides methods for setting the title, image, and other appearance properties of a button. By using theseaccessors, you can specify a different appearance for each button state.(ios官方文档解释)

Creating Buttons

类方法:buttonWithType:

+ (id)buttonWithType:(UIButtonType)buttonType

参数:

typedefenum{

UIButtonTypeCustom=0,--No button style

UIButtonTypeSystem,--A system style button, such as those shown in navigation bars andtoolbars(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 thesetTitleColor:forState:andsetTitleShadowColor: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

参考资料:

View Programming Guide for iOS.

Buttons.

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航