用处:多分段选择控件,选中某个分段会触发值改变事件。
-(void)viewDidLoad
{
[super viewDidLoad];
NSArray* items = @[@"a",@"b",@"c"];
self.seg = [[UISegmentedControl alloc]initWithItems:items];
CGRect frame = CGRectMake(20,20,180,50);
self.seg.frame = frame;
//设置索引的标题
[self.seg setTitle:@"two" forSegmentAtIndex:1];
//设置默认选择器索引
self.seg.selectedSegmentIndex = 1;
//设置底色
self.seg.tintColor = [UIColor redColor];
//设置样式
self.seg.segmentedControlStyle = UISegmentedControlStyleBar;
}
UISegmentedControl控件
时间: 2024-10-11 23:34:47