IOS学习笔记-UIButton_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > IOS学习笔记-UIButton

IOS学习笔记-UIButton

 2015/4/16 15:31:16  泰坦V擎天  程序员俱乐部  我要评论(0)
  • 摘要:AninstanceoftheUIButtonclassimplementsabuttononthetouchscreen.Abuttoninterceptstoucheventsandsendsanactionmessagetoatargetobjectwhentapped.MethodsforsettingthetargetandactionareinheritedfromUIControl.Thisclassprovidesmethodsforsettingthetitle,image
  • 标签:笔记 学习 iOS 学习笔记

UIButton继承关系图

 An instance of the class="code-voice u-api-no-link">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(nonatomicreadonlyretainUILabel *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(nonatomicreadonlyretainNSString *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(nonatomicBOOL adjustsImageWhenHighlighted

 

属性:adjustsImageWhenDisabled

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

@property(nonatomicBOOL adjustsImageWhenDisabled

 

属性:showsTouchWhenHighlighted

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

@property(nonatomicBOOL 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.

发表评论
用户名: 匿名