溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

iOS-UI-基本控件之UISwitch

發(fā)布時間:2020-07-10 23:00:31 來源:網(wǎng)絡(luò) 閱讀:650 作者:591XT_XYZ 欄目:移動開發(fā)

UISwitch(開關(guān),默認為關(guān))

IOS開發(fā)中必不可少的基本控件,主要用于只有兩種的選擇,比如飛行模式等等,本文主要是列出常用的屬性及方法(注XCode版本為7.2)


//默認狀態(tài)

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 ;//感覺像是邊框的顏色,并且?guī)в袆赢嫞?/span>

代碼: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;//是否處于開啟狀態(tài),默認為NO



//方法


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


- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder ;//從XIB加載


- (void)setOn:(BOOL)on animated:(BOOL)animated; // 開的時候是否有動畫


向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI