UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"洗车订单",@"其他订单", nil]];
segment.layer.masksToBounds = YES;
segment.layer.cornerRadius = 15;
segment.layer.borderColor = HKWHITE.CGColor;
segment.layer.borderWidth = 1.0;
//设置默认选择项索引
segment.selectedSegmentIndex = 0;
segment.frame = CGRectMake(0, 5, 180, 30);
segment.tintColor = HKWHITE;
//文字设置
NSMutableDictionary *attDic = [NSMutableDictionary dictionary];
attDic[NSFontAttributeName] = HKFont(15);
NSMutableDictionary *attDicSelected = [NSMutableDictionary dictionary];
attDicSelected[NSFontAttributeName] = HKFont(17);
[segment setTitleTextAttributes:attDic forState:UIControlStateNormal];
[segment setTitleTextAttributes:attDicSelected forState:UIControlStateSelected];
[segment addTarget:self action:@selector(selectSegment:) forControlEvents:UIControlEventValueChanged];
self.navigationItem.titleView = segment;