iOS-UI-UISwith 开关

2016-01-18 19:41:00
  /****** UISwith 开关******/
// frame只有坐标生效, 大小无效由系统默认指定
UISwitch *swt = [[UISwitch alloc] initWithFrame:CGRectMake(100, 200, 0, 0)];
// 注意触发方式
[swt addTarget:self action:@selector(swtAction:) forControlEvents:UIControlEventValueChanged];
// 开关的初始状态
swt.on = YES;
// 开启状态的背景色
swt.onTintColor = [UIColor redColor];
// 边框颜色
swt.tintColor = [UIColor yellowColor];
// 按钮颜色
swt.thumbTintColor = [UIColor blackColor];
[self.view addSubview:swt];
[swt release];

当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »