在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ iOS/ iOS - Switches(切換/開關)
iOS - Switches(切換/開關)
iOS - Labels(標簽)
iOS - Table View(表格視圖)
IOS - 攝像頭管理
iOS - Text View(文本視圖)
IOS - 開發(fā)環(huán)境配置
iOS教程
iOS - Twitter & Facebook
iOS - UI元素
iOS - iAd 整合
IOS - 應用程序調(diào)試
iOS - Split View(分割視圖)
iOS - Status Bar(狀態(tài)欄)
iOS - Navigation Bar(導航欄)
iOS - Tab bar(標簽欄)
IOS - 文件處理
IOS - 自動布局
iOS - Image View(圖像視圖)
iOS - 應用程序內(nèi)購買
iOS - Pickers(選取器)
iOS - Delegates實例
iOS - 創(chuàng)建第一個iPhone應用
iOS (iPhone, iPad)教程
iOS - 發(fā)送電子郵箱(Email)
iOS - View Transitions(視圖轉(zhuǎn)換)
iOS - 內(nèi)存管理
iOS - Icons(圖標)
iOS - 音頻和視頻
iOS - Storyboards(演示圖板演)
iOS - Buttons(按鈕)
iOS - Text Field(文本域)
iOS - Sliders(滑動條)
iOS - Scroll View(滾動視圖)
IOS - 輸入類型 文本字段
iOS - 位置處理
iOS - Accelerometer(加速度傳感器)
IOS - 快速入門
iOS - SQLite 數(shù)據(jù)庫
iOS - GameKit
IOS - 訪問地圖
iOS - Objective-C基礎
iOS - Toolbar(工具欄)
IOS - 動作和插座(Outlets)
iOS - Alerts(警示)
IOS - 通用應用程序

iOS - Switches(切換/開關)

使用開關

開關用于開啟和關閉狀態(tài)之間切換。

 

重要的屬性

  • onImage

  • offImage

  • on

 

重要的方法

- (void)setOn:(BOOL)on animated:(BOOL)animated

 

添加自定義的方法addSwitch和switched:

-(IBAction)switched:(id)sender{
    NSLog(@"Switch current state %@", mySwitch.on ? @"On" : @"Off");
}
-(void)addSwitch{
    mySwitch = [[UISwitch alloc] init];
    [self.view addSubview:mySwitch];
    mySwitch.center = CGYiibaiMake(150, 200);
    [mySwitch addTarget:self action:@selector(switched:)
    forControlEvents:UIControlEventValueChanged];    
}

 

更新在 ViewController.m 中的 viewDidLoad 如下

(void)viewDidLoad
{
   [super viewDidLoad];
   [self addSwitch];
}

輸出

現(xiàn)在,當我們運行程序時,我們會得到下面的輸出。

iOS Tutorial

快速滑動開關的輸出如下。

iOS Tutorial