本文主要是介绍UISwitch 开关,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
UISwitch *swt = [[UISwitch alloc] initWithFrame:CGRectMake(0, 30, 100, 50)];UIImage *on = [UIImage imageNamed:@"smiley_grin_30"];UIImage *off = [UIImage imageNamed:@"smiley_sad_30"];//设置on和off图片,7无效swt.onImage = on;swt.offImage = off;[swt setOn:YES animated:YES];[swt addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];
- (void)change:(UISwitch *)swt
{//获取开关状态//swt.isOn == YES == on//swt.isOn == NO == offif (swt.isOn){NSLog(@"开");}else{NSLog(@"关");}
}
这篇关于UISwitch 开关的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!