標籤:ios ui 基本控制項 uiswitch
UISwitch(開關,預設為關)
IOS開發中必不可少的基本控制項,主要用於只有兩種的選擇,比如飛航模式等等,本文主要是列出常用的屬性及方法(注XCode版本為7.2)
//預設狀態
650) this.width=650;" src="http://s2.51cto.com/wyfs02/M01/7B/73/wKiom1bNfYuiZN_8AAAaOmBnU4o454.png" style="float:none;" title="Simulator Screen Shot 2016年2月24日 下午5.52.45.png" alt="wKiom1bNfYuiZN_8AAAaOmBnU4o454.png" />650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/7B/73/wKiom1bNfYyz2etpAAAauxAC03U053.png" style="float:none;" title="Simulator Screen Shot 2016年2月24日 下午5.52.49.png" alt="wKiom1bNfYyz2etpAAAauxAC03U053.png" />
//屬性
@property(nullable, nonatomic, strong) UIColor *onTintColor ;//開著的時候控制項的顏色
代碼:one.onTintColor=[UIColor brownColor];
650) this.width=650;" src="http://s5.51cto.com/wyfs02/M02/7B/73/wKioL1bNf2bQ2gOYAAAaFU3l5Zs243.png" title="Simulator Screen Shot 2016年2月24日 下午5.58.33.png" alt="wKioL1bNf2bQ2gOYAAAaFU3l5Zs243.png" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/7B/74/wKiom1bNftzi1ButAAAas7pzmKw309.png" title="Simulator Screen Shot 2016年2月24日 下午5.58.36.png" alt="wKiom1bNftzi1ButAAAas7pzmKw309.png" />
@property(null_resettable, nonatomic, strong) UIColor *tintColor ;//感覺像是邊框的顏色,並且帶有動畫,
代碼:one.tintColor=[UIColor redColor];
第二張像個動畫
650) this.width=650;" src="http://s5.51cto.com/wyfs02/M00/7B/91/wKiom1bNn9DjRj_IAAAYPeVwCT4979.png" title="Simulator Screen Shot 2016年2月24日 下午8.18.08.png" alt="wKiom1bNn9DjRj_IAAAYPeVwCT4979.png" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/7B/91/wKiom1bNn_bzuFSmAAAY4vifl2U902.png" title="Simulator Screen Shot 2016年2月24日 下午8.19.36.png" alt="wKiom1bNn_bzuFSmAAAY4vifl2U902.png" />
@property(nullable, nonatomic, strong) UIColor *thumbTintColor ;// 按鈕的顏色
代碼:
one.thumbTintColor=[UIColor blueColor];
650) this.width=650;" src="http://s5.51cto.com/wyfs02/M01/7B/91/wKioL1bNos_gg5lXAAAa2ogvueo294.png" title="Simulator Screen Shot 2016年2月24日 下午8.30.11.png" alt="wKioL1bNos_gg5lXAAAa2ogvueo294.png" />
@property(nonatomic,getter=isOn) BOOL on;//是否處於開啟狀態,預設為NO
//方法
- (instancetype)initWithFrame:(CGRect)frame ; // 設定控制項的大小和起始位置
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder ;//從XIB載入
- (void)setOn:(BOOL)on animated:(BOOL)animated; // 開的時候是否有動畫
本文出自 “紅角羚羊” 部落格,請務必保留此出處http://2254359459.blog.51cto.com/10776102/1744776
IOS-UI-基本控制項之UISwitch