UISwitch

 1 1. onTintColor 
 2   处于on时switch 的颜色
    switchImage.onTintColor = [UIColor grayColor];
 3 2.tintColor 
 4 处于off时switch 的颜色
 5     switchImage.tintColor = [UIColor greenColor];
 6 3.onImage    
 7   设置on 的图标
    switchImage.onImage = [UIImage imageNamed:@"1.png"];
 8 
 9 4. offImage
10    设置off的图标
 switchImage.offImage = [UIImage imageNamed:@"4.png"];
11 
12 5. on
13 设置switch的开关
14 swithImage.on = YES;
15 
16 6.thumbTintColor
17 设置拇指颜色
18 swithImage.thumbTintColor = [UIColor redColor];
19 效果:
20 
21 
22 
23 7.增加事件响应机制
24 监听的是这个事件:UIControlEventValueChanged,值改变事件
25 [switchImage addTarget:self action:@selector(switchOn) forControlEvents:UIControlEventValueChanged];

 

posted @ 2015-05-21 17:40  王世桢  阅读(298)  评论(0编辑  收藏  举报