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;
}
}