怎么发布自己做的网站,免费行情软件网站下载安装,给新公司建网站,自己网站怎么建设UISwtch 在许多场景中会使用到#xff0c;通常用来坐设置开关等行为。下面我们来看一下IOS 中 UISwitch 等用法。注意#xff1a;UISwitch 无法通过 frame 设置宽高 UISwitch* _switch [[UISwitch alloc] init];// 设置状态和开启动画[_switch setOn:NO animated:YES];// 设… UISwtch 在许多场景中会使用到通常用来坐设置开关等行为。下面我们来看一下IOS 中 UISwitch 等用法。注意UISwitch 无法通过 frame 设置宽高 UISwitch* _switch [[UISwitch alloc] init];// 设置状态和开启动画[_switch setOn:NO animated:YES];// 设置开启状态颜色[_switch setOnTintColor: [MyUI getThemeColor]];// 设置位置_switch.frame CGRectMake(100, 100, 0, 0);// 绑定事件[_switch addTarget:self action:selector(change:) forControlEvents:UIControlEventValueChanged];[self.view addSubview:_switch];属性
名称类型说明默认值onTintColorUIColor风格颜色nilthumbTintColorUIColor原点颜色whiteColoronImageUIImage开启状态显示图片niloffImageUIImage关闭状态显示图片nilstyleUISwitchStyle开关的样式可修改大小UISwitchStyleonBOOL开关的状态NO
API - (instancetype)initWithFrame:(CGRect)frame 创建UISwitch同时设置位置 - (void)setOn:(BOOL)on animated:(BOOL)animated 设置状态并开启动画