标签:
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:nil];
segmentedControl.tintColor = [UIColor orangeColor]; //渲染色彩
[segmentedControl insertSegmentWithTitle:@"专家介绍"atIndex:0 animated:NO];
[segmentedControl insertSegmentWithTitle:@"问题解答"atIndex:1 animated:NO];
segmentedControl.selectedSegmentIndex = 0; //初始指定第0个选中
// [segmentedControl addTarget:self action:@selector(controlPressed:)
// forControlEvents:UIControlEventValueChanged];
// 第一种方法
// [self.navigationItem setTitleView:segmentedControl];
// 第二种方法
[self.navigationController.navigationBar.topItem setTitleView:segmentedControl];
iOS在导航栏上居中显示分段控件(UISegmentedControl)
标签:
原文地址:http://www.cnblogs.com/KiVen2015/p/5305654.html