您的位置:首页 > 产品设计 > UI/UE

UISegmentControl/多段选择视图

2015-07-08 08:46 441 查看
UISegmentControl/多段选择视图

NSArray *array=[NSArray arrayWithObjects:@"First",@"Second",@"Third", nil];

1、分段选择控件
UISegmentedControl *sc=[[UISegmentedControl alloc] initWithItems:array];
[sc setFrame:CGRectMake(50, 200, 200, 50)];

2、设置控件颜色
sc.tintColor=[UIColor redColor];

3、默认选择起始位置
sc.selectedSegmentIndex=1;



4、自适应内容,(哪个宽加宽哪个框)
sc.apportionsSegmentWidthsByContent=YES;



5、改变内容
[sc setTitle:@"Thir d" forSegmentAtIndex:2];



6、添加事件
[sc addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];

7、添加控件
[self.view addSubview:sc];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: