UISegmentedControl相关代码如下:
- (UISegmentedControl *)creatUISegmentedControl
{
_segmentControl=[[UISegmentedControl alloc]initWithItems:@[@"待发货",@"待收货"]];
_segmentControl.segmentedControlStyle = UISegmentedControlStyleBordered;
_segmentControl.frame = CGRectMake(10, 5, 300, 30);
_segmentControl.selectedSegmentIndex = 1;
_segmentControl.tintColor = RGB(255, 106, 34);
[_segmentControl addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];
return _segmentControl;
}
-(void)change:(UISegmentedControl *)segmentControl
{
NSLog(@"segmentControl %d",(int)segmentControl.selectedSegmentIndex);
}