UIButton解析(iOS7)
来源:互联网 发布:android系统源码是什么 编辑:程序博客网 时间:2024/05/16 04:20
@1.创建按钮
(+ (id)buttonWithType:(UIButtonType)buttonType;// 创建并返回一个特定风格的按钮)
typedef NS_ENUM(NSInteger, UIButtonType) {
UIButtonTypeCustom = 0, // 自定义风格
UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0), // standard system button
UIButtonTypeDetailDisclosure, // 蓝色小箭头按钮,主要做详细说明用,push出下一层内容
UIButtonTypeInfoLight, // 亮色感叹号
UIButtonTypeInfoDark, // 暗色感叹号
UIButtonTypeContactAdd, // 十字加号按钮
UIButtonTypeRoundedRect = UIButtonTypeSystem, // Deprecated, use UIButtonTypeSystem instead (iOS7)
};
@2.指定button在View上的位置
button.frame = CGRectMake(30,50,100,150);
@3.给button设置标签,用来辨别点击的是哪个button,常用在委托方法中。
button.tag = 0;
@4.定义按钮标题
[button setTitle:@"zhaohuandeyoutiao"forState:UIControlStateNormal];
forState: 这个参数的作用是定义按钮的文字或图片在何种状态下才会显现*/
//以下是几种状态
enum {
UIControlStateNormal = 0, // 常规状态显现
UIControlStateHighlighted = 1 << 0, // 高亮状态显现
UIControlStateDisabled = 1 << 1, // 禁用的状态才会显现
UIControlStateSelected = 1 << 2, // 选中状态
UIControlStateApplication = 0x00FF0000, // 当应用程序标志时
UIControlStateReserved = 0xFF000000 // 为内部框架预留,可以不管他
};
@5.定义按钮标题字体格式
[button.titleLabel setFont:[UIFont boldSystemFontOfSize:100]];
@6.将button设置为图片
[button setImage:[UIImage imageNamed:@"iPhone.png"] forState:UIControlStateNormal];
@7.给button添加背景图片
[button setBackgroundImage:[UIImage imageNamed:@"login.png"] forState:UIControlStateNormal];
@8.给button添加委托方法(点击触发的事件)
[button addTarget:selfaction:@selector(touchButton:) forControlEvents :UIControlEventTouchUpInside];
forControlEvents:
UIControlEventTouchDown =1 << 0, // 按下
UIControlEventTouchDownRepeat =1 << 1, // 多次按下
UIControlEventTouchDragInside =1 << 2, // 保持按下然后再按钮及一定的外围拖动
UIControlEventTouchDragOutside =1 << 3, // 保持按下,在按钮外面拖动
UIControlEventTouchDragEnter =1 << 4, // DragOutside进入DragInside触发
UIControlEventTouchDragExit =1 << 5, // in到out触发
UIControlEventTouchUpInside =1 << 6, // 在按钮以及一定外围内松开(最常用)
UIControlEventTouchUpOutside =1 << 7, // 按钮外面松开
UIControlEventTouchCancel =1 << 8, // 点击取消
- UIButton解析(iOS7)
- UIButton 解析
- UIButton 使用全面解析
- UIButton 使用全面解析
- UIButton 使用全面解析
- UIButton 使用全面解析
- iOS-UIButton 全面解析
- iOS-UIButton 全面解析
- Button按钮解析(iOS7)
- IOS7 UIView 中添加UIButton不响应事件
- iOS7/8 UIButton高亮状态延迟问题全解
- iOS7/8 UIButton高亮状态延迟问题全解
- iOS7 UITableView视图结构解析
- iOS7的iBeacon技术解析
- iOS7后台机制大解析
- UIButton中的UIActionSheet操作表参数解析
- UIKIT详解之UIButton全面解析
- UIButton
- 基础复习------变量及常量的使用
- Jmeter--使用JMeter进行性能测试(Java请求)
- PKU 1509 Glass Beads (最小表示法)
- POJ-3398-Perfect Service
- 线段树简单题
- UIButton解析(iOS7)
- 偶的Android 视频学习之路
- sql oracle如何删除某一用户下所有表数据
- Linux进程间通信-基于内存(共享内存)
- Spring源码学习MVC:HandlerMapping的注册与查找
- uva 10006 Carmichael Numbers
- 查询多个表放在一个集合中用union做连接
- Android与服务器端数据交互(基于SOAP协议整合android+webservice)
- ios中摄像头/相册获取图片,压缩图片,上传服务器方法总结