只要选中了一个片段,你的动作方法就会被调用:
复制代码
-(void)selected:(id)sender{
UISegmentedControl* control = (UISegmentedControl*)sender;
switch (control.selectedSegmentIndex) {
case 0:
//
break;
case 1:
//
break;
case 2:
//
break;
default:
break;
}
}
十、设置圆角以及设置选中颜色为空
复制代码
UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:@"设置",@"知道了", nil]];
seg.frame = CGRectMake(10,0, CGRectGetWidth(self.view.frame) - 20, 35);
seg.center = isbluetoothOffAlerView.center;
seg.layer.borderColor = [UIColor whiteColor].CGColor;
seg.layer.borderWidth = 2;
seg.tintColor = [UIColor whiteColor];
seg.backgroundColor = [UIColor clearColor];
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName,[UIFont systemFontOfSize:24],NSFontAttributeName,nil];
[seg setTitleTextAttributes:dic forState:UIControlStateNormal];
seg.layer.cornerRadius = 15;
seg.layer.masksToBounds = YES;
注:相关教程知识阅读请移步到IOS开发频道。










