UIButton头文件学习
2016-02-15 14:06
483 查看
UIButtonType枚举:
UIButtonTypeCustom 自定义按钮类型
UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0), 系统按钮类型
UIButtonTypeDetailDisclosure, 蓝色小箭头按钮
UIButtonTypeInfoLight,
亮色感叹号
UIButtonTypeInfoDark, 暗色感叹号
UIButtonTypeContactAdd, 十字加号按钮
UIButtonTypeRoundedRect = UIButtonTypeSystem, 已过时,使用UIButtonTypeSystem替代
UIButton继承体系:
UIButton -> UIControl ->UIView
常用的属性:
@property(nonatomic)
UIEdgeInsets contentEdgeInsets
UI_APPEARANCE_SELECTOR;
按钮内容间距
@property(nonatomic)
UIEdgeInsets titleEdgeInsets; 按钮标题间距
@property(nonatomic)
BOOL reversesTitleShadowWhenHighlighted; 标题的阴影改变时,按钮是否高亮显示。默认为NO
@property(nonatomic)
UIEdgeInsets imageEdgeInsets; 按钮图片间距
@property(nonatomic)
BOOL adjustsImageWhenHighlighted; 按钮高亮的情况下,图像的颜色是否要加深一点。默认是YES
@property(nonatomic)
BOOL adjustsImageWhenDisabled; 按钮禁用的情况下,图像的颜色是否要加深一点。默认是YES
@property(nonatomic)
BOOL showsTouchWhenHighlighted
__TVOS_PROHIBITED;按下按钮是否会发光。默认是NO
设置按钮不同状态下外观的一系列方法(set):
- (void)setTitle:(nullable
NSString *)title forState:(UIControlState)state;
// default is nil. title is assumed to be single line
- (void)setTitleColor:(nullable
UIColor *)color forState:(UIControlState)state
UI_APPEARANCE_SELECTOR;
// default if nil. use opaque white
- (void)setTitleShadowColor:(nullable
UIColor *)color forState:(UIControlState)state
UI_APPEARANCE_SELECTOR;
// default is nil. use 50% black
- (void)setImage:(nullable
UIImage *)image forState:(UIControlState)state;
// default is nil. should be same size if different for different states
- (void)setBackgroundImage:(nullable
UIImage *)image forState:(UIControlState)state
UI_APPEARANCE_SELECTOR;
// default is nil
- (void)setAttributedTitle:(nullable
NSAttributedString *)title forState:(UIControlState)state
NS_AVAILABLE_IOS(6_0);
// default is nil. title is assumed to be single line
获取按钮不同状态下外观的一系列方法(get)
- (nullable
NSString *)titleForState:(UIControlState)state;
// these getters only take a single state value
- (nullable UIColor *)titleColorForState:(UIControlState)state;
- (nullable UIColor *)titleShadowColorForState:(UIControlState)state;
- (nullable UIImage *)imageForState:(UIControlState)state;
- (nullable UIImage *)backgroundImageForState:(UIControlState)state;
- (nullable NSAttributedString *)attributedTitleForState:(UIControlState)state
NS_AVAILABLE_IOS(6_0);
获取按钮当前状态下的一系列属性(get)
@property(nullable,
nonatomic,readonly,strong)
NSString *currentTitle;
// normal/highlighted/selected/disabled. can return nil
@property(nonatomic,readonly,strong)
UIColor *currentTitleColor;
// normal/highlighted/selected/disabled. always returns non-nil. default is white(1,1)
@property(nullable,
nonatomic,readonly,strong)
UIColor *currentTitleShadowColor;
// normal/highlighted/selected/disabled.
@property(nullable,
nonatomic,readonly,strong)
UIImage *currentImage;
// normal/highlighted/selected/disabled. can return nil
@property(nullable,
nonatomic,readonly,strong)
UIImage *currentBackgroundImage;
// normal/highlighted/selected/disabled. can return nil
@property(nullable,
nonatomic,readonly,strong)
NSAttributedString *currentAttributedTitle
NS_AVAILABLE_IOS(6_0);
// normal/highlighted/selected/disabled. can return nil
UIButtonTypeCustom 自定义按钮类型
UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0), 系统按钮类型
UIButtonTypeDetailDisclosure, 蓝色小箭头按钮
UIButtonTypeInfoLight,
亮色感叹号
UIButtonTypeInfoDark, 暗色感叹号
UIButtonTypeContactAdd, 十字加号按钮
UIButtonTypeRoundedRect = UIButtonTypeSystem, 已过时,使用UIButtonTypeSystem替代
UIButton继承体系:
UIButton -> UIControl ->UIView
常用的属性:
@property(nonatomic)
UIEdgeInsets contentEdgeInsets
UI_APPEARANCE_SELECTOR;
按钮内容间距
@property(nonatomic)
UIEdgeInsets titleEdgeInsets; 按钮标题间距
@property(nonatomic)
BOOL reversesTitleShadowWhenHighlighted; 标题的阴影改变时,按钮是否高亮显示。默认为NO
@property(nonatomic)
UIEdgeInsets imageEdgeInsets; 按钮图片间距
@property(nonatomic)
BOOL adjustsImageWhenHighlighted; 按钮高亮的情况下,图像的颜色是否要加深一点。默认是YES
@property(nonatomic)
BOOL adjustsImageWhenDisabled; 按钮禁用的情况下,图像的颜色是否要加深一点。默认是YES
@property(nonatomic)
BOOL showsTouchWhenHighlighted
__TVOS_PROHIBITED;按下按钮是否会发光。默认是NO
设置按钮不同状态下外观的一系列方法(set):
- (void)setTitle:(nullable
NSString *)title forState:(UIControlState)state;
// default is nil. title is assumed to be single line
- (void)setTitleColor:(nullable
UIColor *)color forState:(UIControlState)state
UI_APPEARANCE_SELECTOR;
// default if nil. use opaque white
- (void)setTitleShadowColor:(nullable
UIColor *)color forState:(UIControlState)state
UI_APPEARANCE_SELECTOR;
// default is nil. use 50% black
- (void)setImage:(nullable
UIImage *)image forState:(UIControlState)state;
// default is nil. should be same size if different for different states
- (void)setBackgroundImage:(nullable
UIImage *)image forState:(UIControlState)state
UI_APPEARANCE_SELECTOR;
// default is nil
- (void)setAttributedTitle:(nullable
NSAttributedString *)title forState:(UIControlState)state
NS_AVAILABLE_IOS(6_0);
// default is nil. title is assumed to be single line
获取按钮不同状态下外观的一系列方法(get)
- (nullable
NSString *)titleForState:(UIControlState)state;
// these getters only take a single state value
- (nullable UIColor *)titleColorForState:(UIControlState)state;
- (nullable UIColor *)titleShadowColorForState:(UIControlState)state;
- (nullable UIImage *)imageForState:(UIControlState)state;
- (nullable UIImage *)backgroundImageForState:(UIControlState)state;
- (nullable NSAttributedString *)attributedTitleForState:(UIControlState)state
NS_AVAILABLE_IOS(6_0);
获取按钮当前状态下的一系列属性(get)
@property(nullable,
nonatomic,readonly,strong)
NSString *currentTitle;
// normal/highlighted/selected/disabled. can return nil
@property(nonatomic,readonly,strong)
UIColor *currentTitleColor;
// normal/highlighted/selected/disabled. always returns non-nil. default is white(1,1)
@property(nullable,
nonatomic,readonly,strong)
UIColor *currentTitleShadowColor;
// normal/highlighted/selected/disabled.
@property(nullable,
nonatomic,readonly,strong)
UIImage *currentImage;
// normal/highlighted/selected/disabled. can return nil
@property(nullable,
nonatomic,readonly,strong)
UIImage *currentBackgroundImage;
// normal/highlighted/selected/disabled. can return nil
@property(nullable,
nonatomic,readonly,strong)
NSAttributedString *currentAttributedTitle
NS_AVAILABLE_IOS(6_0);
// normal/highlighted/selected/disabled. can return nil
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 浅析C语言头文件和库的一些问题
- C++ 学习之旅二 说一说C++头文件
- 讲解iOS开发中基本的定位功能实现
- js判断客户端是iOS还是Android等移动终端的方法
- IOS开发环境windows化攻略
- iOS开发之路--微博“更多”页面
- 浅析iOS应用开发中线程间的通信与线程安全问题
- 检测iOS设备是否越狱的方法
- VC++开发中完美解决头文件相互包含问题的方法解析
- 浅析VC++中的头文件包含问题
- C++中头文件的概念与基本编写方法
- .net平台推送ios消息的实现方法
- 探讨Android与iOS,我们将何去何从?