UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[NSLocalizedString(@"gtasks", nil),NSLocalizedString(@"question_hotel", nil)]];
segmentedControl.layer.cornerRadius = 20;
segmentedControl.clipsToBounds = YES;
segmentedControl.tintColor = IWColor(85, 155, 219);
NSDictionary* selectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],
NSForegroundColorAttributeName: [UIColor whiteColor]};
[segmentedControl setTitleTextAttributes:selectedTextAttributes forState:UIControlStateSelected];//设置文字属性
NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],
NSForegroundColorAttributeName: [UIColor whiteColor]};
[segmentedControl setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal];
[segmentedControl setBackgroundImage:[UIImage createImageWithColor:IWColor(59, 91, 154)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[segmentedControl setBackgroundImage:[UIImage createImageWithColor:IWColor(85, 155, 219)] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
segmentedControl.apportionsSegmentWidthsByContent = NO;
self.navigationItem.titleView = segmentedControl;