UISwitch控件-“应用小结”
来源:互联网 发布:湖北农村金融数据 编辑:程序博客网 时间:2024/06/07 06:00
主要涉及到三个问题:
(1)frame的设置:
- 控件的内部固定了其大小:
iOS7之前--79x27 iOS7及之后--51x31
- 可以通过设置其center确定其位置
_switch0.center = CGPointMake(100, 200);
- 可以缩放比例
_switch0.transform = CGAffineTransformMakeScale(0.75, 0.75);
(2)颜色、样式:
- 设置开关开启状态时的颜色,默认为深绿色
@property(nonatomic, retain) UIColor *onTintColor; _switch0.onTintColor=[UIColor redColor];
- 设置开关按钮颜色,默认为白色
@property(nonatomic, retain) UIColor *thumbTintColor; _switch0.thumbTintColor=[UIColor yellowColor]; _switch0.thumbTintColor=[UIColor lightGrayColor];
- 设置开关关闭时的颜色,默认为浅灰
@property(nonatomic, retain) UIColor *tintColor; _switch0.tintColor = [UIColor purpleColor];
- 设置开关开启/关闭状态时的图片(注意:在IOS7后不再起任何作用)
@property(nonatomic, retain) UIImage *onImage;@property(nonatomic, retain) UIImage *offImage;
(3)点击方法:
- 添加点击事件
[_switch0 addTarget:self.viewController action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
- 在该事件中监听其状态
if ([swith isOn]){ preStatus = @"1";//打开 } else { preStatus = @"0";//关闭 }
0 0
- UISwitch控件-“应用小结”
- iphone UISwitch开关控件
- UISlider与UISwitch控件
- UISlider与UISwitch控件
- iOS 控件之 UISwitch
- UISwitch开关控件
- UISwitch开关控件
- UISwitch:开关控件
- UISwitch开关控件
- UISwitch开关控件
- 【UISwitch开关控件】
- 开关控件UISwitch
- IOS--UISwitch 开关控件
- iOS---UISwitch控件
- 开关控件 UISwitch
- UISwitch开关控件
- UISwitch控件修改大小。
- UISwitch用法-以及-自定义UISwitch控件
- Linux C编程实战——第七章 进程控制_项目实现_自写shell
- C++11:基于std::queue和std::mutex构建一个线程安全的队列
- Jump Game
- Keepalived健康检查方式配置
- hdu 2579 Dating with girls(2)
- UISwitch控件-“应用小结”
- Find a way<hdoj2612>
- 2118数据结构实验之链表三:链表的逆置
- hadoop简单实例-WordCount
- Codeforces 204B Little Elephant and Cards
- JS中setTimeout()的用法详解
- java语言基础入门——异常处理
- 使用 Date 和 SimpleDateFormat 类表示时间
- UIScrollView的循环滚动+UIPageControll+NSTimer实现的自动循环滚动播放最终完善版