IOS-UI-基本控制項之UISwitch

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.