UISwitch
版權(quán)聲明:本文為延成原創(chuàng)文章,轉(zhuǎn)載請標(biāo)明出處
@interface UISwitchViewController () {UISwitch* _cSwitch; } @end-(void)createUISwitch{_cSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];[_cSwitch setOn:YES animated:YES];[_cSwitch setOnTintColor:[UIColor redColor]];//開啟時顏色[_cSwitch setThumbTintColor:[UIColor greenColor]];//按鈕顏色[_cSwitch addTarget:self action:@selector(pressSwitch:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:_cSwitch]; }-(void)pressSwitch:(UISwitch*)swit{if (swit.on == YES) {NSLog(@"打開開關(guān)");}else{NSLog(@"關(guān)閉開關(guān)");} }總結(jié)
- 上一篇: Silverlight 2.5D RPG
- 下一篇: 顶级知识管理工具Evernote的GTD