ios基本控件之UISwitch
2016-01-18 13:38
375 查看
switchImage.onTintColor = [UIColor grayColor];
switchImage.tintColor = [UIColor greenColor];
switchImage.onImage = [UIImage imageNamed:@"1.png"];
switchImage.offImage = [UIImage imageNamed:@"4.png"];
swithImage.on = YES;
swithImage.thumbTintColor = [UIColor redColor];
效果:
[switchImage addTarget:self action:@selector(switchOn) forControlEvents:UIControlEventValueChanged];
UISwitch属性
1. onTintColor
处于on时switch 的颜色switchImage.onTintColor = [UIColor grayColor];
2.tintColor
处于off时switch 的颜色switchImage.tintColor = [UIColor greenColor];
3.onImage
设置on 的图标switchImage.onImage = [UIImage imageNamed:@"1.png"];
4. offImage
设置off的图标switchImage.offImage = [UIImage imageNamed:@"4.png"];
5. on
设置switch的开关swithImage.on = YES;
6.thumbTintColor
设置拇指颜色swithImage.thumbTintColor = [UIColor redColor];
效果:
7.增加事件响应机制
监听的是这个事件:UIControlEventValueChanged,值改变事件[switchImage addTarget:self action:@selector(switchOn) forControlEvents:UIControlEventValueChanged];
相关文章推荐
- ios基本控件之UISegmentControl
- 1月18号 UIButton
- ios基本控件之UISlide
- ios基本控件之UIScrollView
- ios基本控件之UIPickerView
- ios基本控件之UIPageControl
- ios基本控件之UILabel
- ios基本控件之UIImageView
- QUiLoader 动态加载.ui文件
- ios基本控件之UIImagePickerController
- ios基本控件之UIDatePicker
- ios基本控件之UIControl
- ios基本控件之UIButton
- ios基本控件之UIAlertView
- ios基本控件之UIActivityIndicatorView
- amazon oa2 - insert a value into a cycled linked list
- iOS9之后支付宝的回调以及iOS8之后提示框UIAlertController
- UILabel设置富文本格式显示
- 在线安装maven插件问题:Cannot complete the install because one or more required items could not be found.
- 素材收集整理