iOS——UISwitch

来源:互联网 发布:orange软件下载 编辑:程序博客网 时间:2024/06/06 00:06

一、概述

1. UISwitch 是开发中常用的一个控件,较简单
2. UISwitch 控件的的长宽是默认不变的,也就是说,用 initWithFrame: 初始化时,不管传入的 frame 是多少,只会影响 x、y坐标,不会影响 width、height

二、属性

1. 设置开关开启时的颜色

@property(nullable,nonatomic, strong)UIColor *onTintColor;


2. 设置开关闭是时的边框颜色,当开关开启时,颜色全部变为开启时设置的颜色

@property(null_resettable,nonatomic, strong)UIColor *tintColor;


3. 设置开关的按钮颜色

@property(nullable,nonatomic, strong)UIColor *thumbTintColor;


4. 设置开关的开启状态;YES 为开启,NO 为关闭

@property(nonatomic,getter=isOn)BOOL on;


5. 设置开关的开启状态并设置动画效果

- (void)setOn:(BOOL)on animated:(BOOL)animated;


6. 设置开关的开启图片;在 iOS 7 中没有用

@property(nullable,nonatomic, strong)UIImage *onImage;


7. 设置开关的关闭图片;在 iOS 7 中没有用

@property(nullable,nonatomic, strong)UIImage *offImage;

0 0
原创粉丝点击