UISegmentedControl *segmentC = [[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:@"本周周报",@"历史周报", nil]];
segmentC.frame = CGRectMake(0,0, 120, 30);
segmentC.layer.borderColor = [UIColor whiteColor].CGColor;
segmentC.layer.borderWidth = 1;
segmentC.tintColor = [UIColor whiteColor];
segmentC.backgroundColor = [UIColor clearColor];
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName,[UIFont systemFontOfSize:14],NSFontAttributeName,nil];
[segmentC setTitleTextAttributes:dic forState:UIControlStateNormal];
segmentC.layer.cornerRadius = 15.0f;
segmentC.layer.masksToBounds = YES;
segmentC.tintColor = [UIColor whiteColor];
self.navigationItem.titleView = segmentC;
转载于:https://my.oschina.net/u/2532565/blog/536601