IOS开发笔记之十九——UIButton的使用总结
2015-01-14 19:36
337 查看
1、基本属性
//设置UIButton标题:
[button setTitle:@"title" forState:UIControlStateNormal];
//设置UIButton标题颜色:
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//设置UIButton背景图片和填充图片:
[button setBackgroundImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal];
//设置UIButton背景颜色:
button.backgroundColor = [UIColor clearColor];
//设置UIButton按钮字体的大小:
button.titleLabel.font = [UIFont systemFontOfSize:26.0];//设置按钮上字体的大小
[button setTintColor:[UIColor whiteColor]];
2、button添加点击事件
[button addTarget:self action:@selector(onAction) forControlEvents:UIControlEventTouchUpInside];
addTarget:self 是链接到self,一般都这样设置
action:@selector(alarmTimeDone:) 时间处理函数
forControlEvents:UIControlEventTouchUpInside 控件事件处理的消息
删除点击事件,用下面方法:
- (void)removeTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
3、image与title属性的设置。。
4、未完待续。。
//设置UIButton标题:
[button setTitle:@"title" forState:UIControlStateNormal];
//设置UIButton标题颜色:
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//设置UIButton背景图片和填充图片:
[button setBackgroundImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal];
//设置UIButton背景颜色:
button.backgroundColor = [UIColor clearColor];
//设置UIButton按钮字体的大小:
button.titleLabel.font = [UIFont systemFontOfSize:26.0];//设置按钮上字体的大小
[button setTintColor:[UIColor whiteColor]];
2、button添加点击事件
[button addTarget:self action:@selector(onAction) forControlEvents:UIControlEventTouchUpInside];
addTarget:self 是链接到self,一般都这样设置
action:@selector(alarmTimeDone:) 时间处理函数
forControlEvents:UIControlEventTouchUpInside 控件事件处理的消息
删除点击事件,用下面方法:
- (void)removeTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
3、image与title属性的设置。。
4、未完待续。。
相关文章推荐
- iOS开发笔记18--SEL (@selector) 原理及使用总结(二)
- IOS开发笔记之十八——UILabel的使用总结
- iOS开发笔记17-SEL (@selector) 原理及使用总结(一)
- IOS开发笔记之十四——使用系统相册或相机导致状态栏隐藏的问题(bug总结四)
- 【iOS开发】关于UIView总结与UIButton使用
- iOS开发学习笔记之UIButton的使用
- iOS开发中UIButton的使用方法总结
- IOS开发学习笔记(十九)——Core Data使用(上篇)
- 我的iphone开发学习笔记(二)使用UITextView, UITextField 和UIButton控件
- IOS开发基础教程学习笔记3 使用Tab Bar切换视图
- iOS开发笔记(六):UIButton需要注意的几个地方
- IOS开发学习笔记(四)——使用TableView
- iOS开发笔记--iOS开发 使用NSUserDefaults 保存数据
- iOS开发那些事-Git在Xcode中的配置与使用常见问题总结
- IOS开发学习笔记(二十一)——Core Data使用(下篇)
- IOS开发学习笔记(十八)——使用地理位置及地图(下篇)
- [ios前端开发笔记]使用scrollView进行分页
- IOS开发学习笔记(十一)——ObjectC中集合类型的使用
- IOS开发学习笔记(2)-----UIButton 详解(原创)
- IOS开发学习笔记(十六)——使用地理位置及地图(上篇)