UIButton
2015-12-25 16:09
288 查看
UIButton
按钮在开发时候能想到这个功能既要显示图片又要显示文字优先选择按钮。按钮的状态 ##
按钮的状态:默认,高亮,失效。状态都是以枚举常量值来定义的。默认状态
枚举值:UIControlStateNormal
高亮
枚举值:UIControlStateHighlighted
不可点击状态(当enable属性为NO,就是出于disable代表不可点击)
枚举值:UIControlStateDisable
动态改控件的位置
代码改变控件的位置:在ios中不能通过控件的XY轴标直接修改控件的位置。先获取控件的上的frame属性。
CGRect btnFrame = self.btn.frame;
设置X、y的位置
btnFrame.frame.origin.y = 10;
再将frame对象赋值给控件
self.btn.frame = btnFrame;
按钮的属性
按钮的创建,并定义属性创建按钮并定义按钮的类型
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
设按钮状态对应的图片
[btn setBackgroundImage:[UIImage imageNamed:@”tupian”] forState:UIControlSateNormal];
设置对应文字
[btn setTitle:@”点我啊”forState:UIControlStateNormal];
默认状态的文字颜色
[btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
按钮的创建
按钮创建的创建的时候区分类类型UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; UIButtonTypeCustom:无类型,按钮的内容需要自定义 UIButtonTypeInfoLight: UIButtonTypeInfoDark UIButtonTypeContactAdd: //添加按钮 UIButtonTypeDetailDisclosure://详情按钮
相关文章推荐
- 05 Stacks and Queues
- Implement Queue using Stacks 用俩栈实现队列
- iOS开发-简述UITableView中cell的重用问题
- iOS UITableView(一)tableView的创建
- ios UIAlertController 的用法
- How to create a customized field value by executing PHP code
- UITableView的重用机制
- Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for pr
- an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe
- Mosquitto support websocket
- 实现UITextView的placeholder效果
- UI 相关配置 包含wtl 和mfc
- Detail Disclosure Button and Segues
- 两个UIScrollView同步滚动
- [leetcode 288] Unique Word Abbreviation
- cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=../build/ ..
- 代码手写UI,xib和StoryBoard间的博弈,以及Interface Builder的一些小技巧
- Android酷炫实用的开源框架(UI框架)
- IOS 的 7 中手势的介绍 和详细使用(UIGestureRecognizer) UIScreenEdgePanGestureRecognizer
- Executors.newFixedThreadPool和ArrayBlockingQueue一点使用心得