iOS基础一 UISwitch
来源:互联网 发布:java解决int数值上限 编辑:程序博客网 时间:2024/06/05 23:25
/** * UISwitch */ self.mainSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(100, 100, 0, 0)]; //self.mainSwitch = [[UISwitch alloc] initWithFrame:CGRectZero]; //self.mainSwitch.center = self.view.center; [self.mainSwitch setOn:YES]; [self.mainSwitch addTarget:self action:@selector(switchIsChanged:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:self.mainSwitch]; //off-mod color self.mainSwitch.tintColor = [UIColor redColor]; //on-mod color self.mainSwitch.onTintColor = [UIColor brownColor]; //knob's color self.mainSwitch.thumbTintColor = [UIColor greenColor]; //change the uiimage ios6.0 or later //self.mainSwitch.onImage = [UIImage imageNamed:@"on"]; //self.mainSwitch.offImage = [UIImage imageNamed:@"off"];
可以在view中配置如上属性,同时target方法如下:
-(void) switchIsChanged: (UISwitch *)paramSender{ // NSLog(@"sender is %@",paramSender); if([paramSender isOn] == YES) NSLog(@"the switch is turn on"); else NSLog(@"the switch is turn off");}
UISwitch 可以修改on/off 图像 要求图片是宽77 高22 且只有ios6之前版本有效
0 0
- iOS基础一 UISwitch
- iOS开发之基础视图— UISwitch
- IOS基础控件 UISwitch swift3.1
- iOS-UISwitch
- IOS UISwitch
- ios基础控件之开关按钮(UISwitch)
- iOS每日一记之----------------自定义UIswitch 控件
- UIswitch UISlider(基础篇)
- IOS之自定义UISwitch
- IOS之自定义UISwitch
- iOS 控件之 UISwitch
- iOS开发(8)UISwitch
- ios的UISwitch
- IOS自定义UISwitch
- iOS开发--UISwitch用法
- IOS--UISwitch 开关控件
- iOS开发-UISwitch用法
- iOS---UISwitch控件
- 笔记
- UVA 11995 I Can Guess the Data Structure!
- iOS用流的形式上传文件
- 测试android横竖屏切换、按home键、按返回键所触发的生命周期
- 阅读器订阅
- iOS基础一 UISwitch
- 好程序员和差程序员
- JQuery插件第三十八个:表单元素清空
- Java JDBC连接SQL Server2005错误:通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败
- Shmget: Invalid argument. Why i get this error?
- ios email 验证规则
- 八种排序算法效率比较
- sqlserver2005使用row_number() over分页的实现方法
- 猫眼移动科技:IDF14现场智能大搜查