温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

iOS-UI-基本控件之UISwitch

发布时间:2020-07-10 23:00:31 来源:网络 阅读:646 作者:591XT_XYZ 栏目:移动开发

UISwitch(开关,默认为关)

IOS开发中必不可少的基本控件,主要用于只有两种的选择,比如飞行模式等等,本文主要是列出常用的属性及方法(注XCode版本为7.2)


//默认状态

iOS-UI-基本控件之UISwitchiOS-UI-基本控件之UISwitch


//属性

@property(nullable, nonatomic, strong) UIColor *onTintColor ;//开着的时候控件的颜色

代码:one.onTintColor=[UIColor brownColor];

如图:

iOS-UI-基本控件之UISwitchiOS-UI-基本控件之UISwitch


@property(null_resettable, nonatomic, strong) UIColor *tintColor ;//感觉像是边框的颜色,并且带有动画,

代码:one.tintColor=[UIColor redColor];

如图:第二张像个动画

iOS-UI-基本控件之UISwitchiOS-UI-基本控件之UISwitch


@property(nullable, nonatomic, strong) UIColor *thumbTintColor ;// 按钮的颜色

代码:

 one.thumbTintColor=[UIColor blueColor];

如图:

iOS-UI-基本控件之UISwitch




@property(nonatomic,getter=isOn) BOOL on;//是否处于开启状态,默认为NO



//方法


- (instancetype)initWithFrame:(CGRect)frame ;      // 设置控件的大小和起始位置


- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder ;//从XIB加载


- (void)setOn:(BOOL)on animated:(BOOL)animated; // 开的时候是否有动画


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI