UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"洗车订单",@"其余订单", nil]];orm
segment.layer.masksToBounds = YES;索引
segment.layer.cornerRadius = 15;get
segment.layer.borderColor = HKWHITE.CGColor;it
segment.layer.borderWidth = 1.0;io
//设置默认选择项索引table
segment.selectedSegmentIndex = 0;select
segment.frame = CGRectMake(0, 5, 180, 30);dict
segment.tintColor = HKWHITE;tab
//文字设置di
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;