UIButton
2015-07-29 22:35
423 查看
用button自己的便利构造器的方式来创建对象
指定button的位置和大小
设置背景颜色
给button设置标题
设置button标题的字体大小
设置圆角
设置边框
点击方法
button最重要的部分
UIButton *button =[UIButton buttonWithType:UIButtonTypeSystem];
指定button的位置和大小
button.frame=CGRectMake(100, 100, 100, 70);
设置背景颜色
button.backgroundColor=[UIColor yellowColor]; [self.window addSubview:button];
// button是便利构造器,不需要release
给button设置标题
[button setTitle:@"确认" forState:UIControlStateNormal]; // 通常情况下,字体显示,点击的时候字体不显示 // 还有disable等状态
设置button标题的字体大小
button.titleLabel.font=[UIFont systemFontOfSize:14];
设置圆角
button.layer.cornerRadius=10; button.layer.masksToBounds=YES;
设置边框
// 宽度 button.layer.borderWidth=7; // 颜色 borderColor
点击方法
button最重要的部分
[button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
相关文章推荐
- GCD介绍(一):基本概念和Dispatch Queue
- UIView属性学习
- CF_484B_MaximumValue
- iOS"Request failed: unacceptable content-type: text/html"
- CF_288B_PoloThePenguinAndHouses
- UIView
- UI的类--UIView
- 使用JS给value属性赋值的实例
- The Dole Queue
- UILabel
- vector\list\deque的选取
- [iOS]UILable文字如何在顶部
- UI04_UIButton
- CharSequence与String区别
- Snail—UI学习之弹出按钮选择项UIActionSheet
- Snail—UI学习之旋转进度轮UIActivityIndicatorView
- Snail—UI学习之提醒框UIAlertView
- iOS UIAlertView
- 使用GXT的ThemeBuilder建立自己的皮肤
- Snail—UI学习之自定义标签栏UITabBarController