UIButton详细的属性介绍
来源:互联网 发布:文件管理器源码 编辑:程序博客网 时间:2024/06/05 15:23
第一、UIButton的定义 UIButton *button=[[UIButton buttonWithType:(UIButtonType);能够定义的button类型有以下6种, typedef enum { UIButtonTypeCustom = 0, 自定义风格 UIButtonTypeRoundedRect, 圆角矩形 UIButtonTypeDetailDisclosure, 蓝色小箭头按钮,主要做详细说明用 UIButtonTypeInfoLight, 亮色感叹号 UIButtonTypeInfoDark, 暗色感叹号UIButtonTypeContactAdd, 十字加号按钮 } UIButtonType;第二、设置framebutton1.frame = CGRectMake(20, 20, 280, 40);[button setFrame:CGRectMake(20,20,50,50)];第三、button背景色button1.backgroundColor = [UIColor clearColor];[button setBackgroundColor:[UIColor blueColor]];第四、state状态 forState: 这个参数的作用是定义按钮的文字或图片在何种状态下才会显现enum {UIControlStateNormal = 0, 常规状态显现 UIControlStateHighlighted = 1 << 0, 高亮状态显现 UIControlStateDisabled = 1 << 1, 禁用的状态才会显现 UIControlStateSelected = 1 << 2, 选中状态 UIControlStateApplication = 0x00FF0000, 当应用程序标志时 UIControlStateReserved = 0xFF000000 为内部框架预留,可以不管他 };@property(nonatomic,getter=isEnabled)BOOL enabled; // default is YES. if NO, ignores touch events and subclasses may draw differently@property(nonatomic,getter=isSelected)BOOL selected; // default is NO may be used by some subclasses or by application@property(nonatomic,getter=isHighlighted)BOOL highlighted; 第五 、设置button填充图片和背景图片 [buttonsetImage:[UIImageimageNamed:@"checkmarkControllerIcon"]forState:UIControlStateNormal]; [buttonsetBackgroundImage:[UIImageimageNamed:@"checkmarkControllerIcon"]forState:UIControlStateNormal];第六、设置button标题和标题颜色[button1 setTitle:@"点击" forState:UIControlStateNormal]; [buttonsetTitleColor:[UIColorredColor]forState:UIControlStateNormal];第七、设置按钮按下会发光 button.showsTouchWhenHighlighted=NO;第八、添加或删除事件处理[button1 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];[btn removeTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];第九、 设置按钮内部图片间距和标题间距 UIEdgeInsets insets; // 设置按钮内部图片间距 insets.top = insets.bottom = insets.right = insets.left = 10; bt.contentEdgeInsets = insets; bt.titleEdgeInsets = insets; // 标题间距
0 0
- UIButton详细的属性介绍
- UIButton的详细介绍:
- 你真的会用UIButton吗? UIButton详细介绍
- UIButton的contentEdgeInsets等三个属性介绍
- iOS UIButton详细介绍
- UIButton常用属性介绍lzp
- UIButton的详细使用
- UIButton的详细使用
- UIButton的详细使用
- UIButton 的详细解释
- 扩展UIButton的属性
- UIButton的一些属性
- UIButton的属性
- UIButton的adjustsImageWhenHighlighted属性
- UIButton的常用属性
- UIButton 的一些属性
- UIButton的contentEdgeInsets属性
- UIButton的基本属性
- How To Install and Configure Django with Postgres, Nginx, and Gunicorn
- Android源码分享之一-----练手项目
- [leetcode] 23. Merge k Sorted Lists 解题报告
- 20.sed的简单使用
- 1030: [JSOI2007]文本生成器 AC自动机+DP
- UIButton详细的属性介绍
- 解决PHP SOAP 间歇性错误 Solution: Soap WSDL Error - "failed to load external entity"
- Linux入门学习笔记
- 简单工厂模式
- Android studio 安装配置记录
- Nginx
- Nginx-start
- 深入理解计算机系统知识汇总 v1.0
- linux挂载光盘与u盘-44