iOS——UIButton
来源:互联网 发布:java 静态导入 编辑:程序博客网 时间:2024/06/04 20:51
一、概述
1. 说明
UIButton 继承 UIControl(基本控件类)
2. 属性
+ (instancetype)buttonWithType:(UIButtonType)buttonType;
UIButtonType 枚举如下 :
typedef NS_ENUM(NSInteger, UIButtonType) { UIButtonTypeCustom = 0, // 无风格,创建带图片的按钮需要这种风格 UIButtonTypeSystem, // 系统风格 UIButtonTypeDetailDisclosure, // 显示详细按钮 UIButtonTypeInfoLight, // 亮色感叹号按钮 UIButtonTypeInfoDark, // 暗色感叹号按钮 UIButtonTypeContactAdd, // 加号按钮 UIButtonTypeRoundedRect = UIButtonTypeSystem, // 圆角按钮,被废弃,使用 UIButtonTypeSystem 代替 };
2)保存 UIButton 对象的风格
@property(nonatomic,readonly)UIButtonType buttonType;
3)获取按钮的标题label(在按钮上有一个label)
@property(nullable,nonatomic,readonly,strong)UILabel * titleLabel;
4)获取按钮的图片视图
@property(nullable,nonatomic,readonly,strong)UIImageView *imageView;
5)设置按钮的 标题label 的标题和状态
- (void)setTitle:(nullableNSString *)title forState:(UIControlState)state;
UIControlState 枚举如下 :
typedef NS_OPTIONS(NSUInteger, UIControlState) { UIControlStateNormal = 0, // 正常状态 UIControlStateHighlighted = 1 << 0, // 按下状态(当按下按钮时) UIControlStateDisabled = 1 << 1, // 禁用状态(无法响应事件,可以通过 enable 属性设置为 NO 也是此状态) UIControlStateSelected = 1 << 2, // 选中状态(可以响应事件,可以通过 selected 属性设置为 YES 也是此状态) UIControlStateFocused = 1 << 3, // 聚焦状态,iOS9才有 UIControlStateApplication = 0x00FF0000, // 当用作应用标志时 UIControlStateReserved = 0xFF000000 //内部框架预留,无意义 };
- (void)setTitleColor:(nullableUIColor *)color forState:(UIControlState)state;
7)设置按钮的 标题label 的引用颜色和状态
- (void)setTitleShadowColor:(nullableUIColor *)color forState:(UIControlState)state ;
8)设置按钮的 图片和状态
- (void)setImage:(nullableUIImage *)image forState:(UIControlState)state;
9)设置背景图片和状态
- (void)setBackgroundImage:(nullableUIImage *)image forState:(UIControlState)state;
10)设置属性标题和状态
- (void)setAttributedTitle:(nullableNSAttributedString *)title forState:(UIControlState)state;
11)返回指定状态的标题
- (nullableNSString *)titleForState:(UIControlState)state;
12)返回指定状态的标题颜色
- (nullableUIColor *)titleColorForState:(UIControlState)state;
13)返回指定状态的标题阴影颜色
- (nullableUIColor *)titleShadowColorForState:(UIControlState)state;
14)返回指定状态的图片
- (nullableUIImage *)imageForState:(UIControlState)state;
15)返回指定状态的背景图片
- (nullableUIImage *)backgroundImageForState:(UIControlState)state;
16)返回指定状态的属性字符串
- (nullableNSAttributedString *)attributedTitleForState:(UIControlState)state;
17)返回当前状态的标题
@property(nullable,nonatomic,readonly,strong)NSString *currentTitle;
17)返回当前状态的标题颜色
@property(nonatomic,readonly,strong)UIColor *currentTitleColor;
19)返回当前状态的标题阴影颜色
@property(nullable,nonatomic,readonly,strong)UIColor *currentTitleShadowColor;
20)返回当前状态的图片
@property(nullable,nonatomic,readonly,strong)UIImage *currentImage;
21)返回当前状态的背景图片
@property(nullable,nonatomic,readonly,strong)UIImage *currentBackgroundImage;
22)返回当前状态的属性字符串
@property(nullable,nonatomic,readonly,strong)NSAttributedString *currentAttributedTitle;
- iOS——UIButton
- iOS — UIButton
- IOS学习——UIButton
- iOS学习(1)——UIButton
- iOS系列UI篇——UIButton
- iOS——UILabel UIButton UITextField
- iOS学习之——UIButton详解
- iOS菜鸟学习——UIButton响应传参数
- iOS学习笔记(七)——UI基础UIButton
- iOS开发控件的简单应用——UIButton
- iOS学习笔记(七)——UI基础UIButton
- iOS系列UI篇——自定义UIButton
- iOS 自定义UIButton点击动画特效 —— HERO博客
- iOS中UIKit——UIButton设置边框
- iOS开发之基础视图——UIButton
- iOS开发之UI篇(7)—— UIButton
- 【IOS】UIButton
- iOS-UIButton
- 【android】ListView工作原理解析
- 找不到activity
- iOS#import和@class区别
- 从《亮剑》中学到的管理方法
- 剑指offer20:顺时针打印矩阵
- iOS——UIButton
- 深入理解Java 8 Lambda(类库篇——Streams API,Collectors和并行)
- 最小路径覆盖(二分图)
- hadoop环境的搭建实例
- Android CPU使用过大的问题解决以及造成的原因
- 欢迎使用CSDN-markdown编辑器
- R编写一个数论中的简单定理
- centos6.5下使用yum完美搭建LNMP环境(php5.6)
- 《递归递推练习》F