UISwitch
版權聲明:本文為延成原創(chuàng)文章,轉載請標明出處
@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(@"打開開關");}else{NSLog(@"關閉開關");} }總結
- 上一篇: Silverlight 2.5D RPG
- 下一篇: 过压保护(1)