IOS UISwitch 组件的使用
生活随笔
收集整理的這篇文章主要介紹了
IOS UISwitch 组件的使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
UISwtch 在許多場景中會使用到,通常用來坐設置開關等行為。下面我們來看一下IOS 中 UISwitch 等用法。注意:UISwitch 無法通過 frame 設置寬高
UISwitch* _switch = [[UISwitch alloc] init];// 設置狀態和開啟動畫[_switch setOn:NO animated:YES];// 設置開啟狀態顏色[_switch setOnTintColor: [MyUI getThemeColor]];// 設置位置_switch.frame = CGRectMake(100, 100, 0, 0);// 綁定事件[_switch addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];[self.view addSubview:_switch];屬性
| onTintColor | UIColor | 風格顏色 | nil |
| thumbTintColor | UIColor | 原點顏色 | whiteColor |
| onImage | UIImage | 開啟狀態顯示圖片 | nil |
| offImage | UIImage | 關閉狀態顯示圖片 | nil |
| style | UISwitchStyle | 開關的樣式,可修改大小 | UISwitchStyle |
| on | BOOL | 開關的狀態 | NO |
API
-
- (instancetype)initWithFrame:(CGRect)frame 創建UISwitch同時設置位置
-
- (void)setOn:(BOOL)on animated:(BOOL)animated 設置狀態并開啟動畫
總結
以上是生活随笔為你收集整理的IOS UISwitch 组件的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JAVA.SQL.SQLNONTRANS
- 下一篇: 日冕物质抛射检测matlab,日冕图像论