UISwitch(开关)
来源:互联网 发布:linux tomcat log4j 编辑:程序博客网 时间:2024/04/27 19:40
//创建一个UISwitch对象(开关对象)
//创建UISwitch对象时,开关按钮的长宽是系统默认的,只可以改变开关的坐标点
UISwitch *Switch = [[UISwitch alloc]initWithFrame:CGRectMake(100, 100, 50, 30)];
Switch.backgroundColor = [UIColor redColor];
[self addSubview:Switch];
//改变开着状态的颜色
Switch.onTintColor = [UIColor blueColor];
//设置开着状态的图片(iOS7后基本不显示了)
Switch.onImage = [[UIImage imageNamed:@"3.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
Switch.offImage = [[UIImage imageNamed:@"3.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
//设置关闭状态下背景颜色
Switch.tintColor = [UIColor cyanColor];
//设置拇指按键的地方的颜色
Switch.thumbTintColor= [UIColor blackColor];
//设置初始化时开关的状态是开着的
Switch.on = YES;
//设置初始化时开关的状态,且开着动画
[Switch setOn:YES animated:YES];
//创建UISwitch对象时,开关按钮的长宽是系统默认的,只可以改变开关的坐标点
UISwitch *Switch = [[UISwitch alloc]initWithFrame:CGRectMake(100, 100, 50, 30)];
Switch.backgroundColor = [UIColor redColor];
[self addSubview:Switch];
//改变开着状态的颜色
Switch.onTintColor = [UIColor blueColor];
//设置开着状态的图片(iOS7后基本不显示了)
Switch.onImage = [[UIImage imageNamed:@"3.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
Switch.offImage = [[UIImage imageNamed:@"3.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
//设置关闭状态下背景颜色
Switch.tintColor = [UIColor cyanColor];
//设置拇指按键的地方的颜色
Switch.thumbTintColor= [UIColor blackColor];
//设置初始化时开关的状态是开着的
Switch.on = YES;
//设置初始化时开关的状态,且开着动画
[Switch setOn:YES animated:YES];
点击事件
//为开关视图绑定事件
[self.rootView.Switch addTarget:self action:@selector(SwitchAction:) forControlEvents:UIControlEventValueChanged];
//设置开关的点击事件
-(void)SwitchAction:(UISwitch *)sender{
if (sender.on == YES) {
NSLog(@"开关开着");
}
else{
NSLog(@"开关关着");
}
}
0 0
- UISwitch 开关
- UISwitch/开关
- UISwitch(开关)
- 开关UISwitch
- iphone UISwitch开关控件
- UISwitch开关控件
- UISwitch开关控件
- UISwitch:开关控件
- UISwitch开关控件
- UI 开关UISwitch
- UISwitch开关控件
- 【UISwitch开关控件】
- 开关控件UISwitch
- IOS--UISwitch 开关控件
- Swift UISwitch(开关)
- iOS开关-UISwitch
- 开关控件 UISwitch
- UISwitch 开关状态
- 真正意义上了解innodb_support_xa(分布式事务)
- 使用Jenkins配置自动化构建
- selenium 用java得到select下拉列表选择的值
- 14->oracle常用的动态性能表
- C++入门经典 笔记 (第十九章)使用链表存储信息
- UISwitch(开关)
- 寻找数组里第K 小的数
- ZOJ 2971 Give Me the Number
- jQueryAutocomplete使用,支持输入中英文模糊匹配
- Google三篇论文中文版
- centos下MySQL安装
- X.509标准简介
- Algorithms—274.H-Index
- iso vpn设置