属性
UISwitch *switchView = [[UISwitch alloc]initWithFrame:CGRectMake(54.0f,16.0f,100.0f,28.0f)];
switchView.on = YES; //设置初始为ON的一边
[switchView setOn:YES];
[switchView addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
-(void)switchAction:(id)sender {
BOOL isButtonOn = [switchButton isOn];
if (isButtonOn) {
showSwitchValue.text = @"是";
}else {
showSwitchValue.text = @"否";
}
}
switchView.transform = CGAffineTransformMakeScale(0.75,0.75);
switchView.onTintColor = [UIColor colorWithRed:0.984 green:0.478 blue:0.224 alpha:1.000];
网友评论