UISegmentedControl详解

NSArray *segmentedArray = [[NSArray alloc]initWithObjects:@”热门”,@”广场”,@”关注”,nil];

UISegmentedControl *segmentedControl = [[UISegmentedControl alloc]initWithItems:segmentedArray];
segmentedControl.frame =CGRectMake(0.0f, 0.0f, 150.0f, 30.0f);
[segmentedControl addTarget:self action:@selector(SelectbuttonAction:) forControlEvents:UIControlEventValueChanged];
segmentedControl.layer.borderWidth = 0.0;
segmentedControl.selectedSegmentIndex=0;
segmentedControl.tintColor = [UIColor colorWithRed:0.69f green:0.75f blue:0.87f alpha:1.00f];
segmentedControl.backgroundColor = [UIColor clearColor];
self.navigationItem.titleView = segmentedControl;

-(void)SelectbuttonAction:(UISegmentedControl *)seg{

NSInteger Index = seg.selectedSegmentIndex;
switch (Index) {
        
    case 0:

        break;
        
    case 1:
        
        
        break;
        
    case 2:
        
        
        break;
        
        
    default:
        
        break;
        
}

}

    原文作者:Eidesen
    原文地址: https://segmentfault.com/a/1190000003745695
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞