iOS在导航栏上居中显示分段控件(UISegmentedControl)

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];

上一篇:如何部署用.net framework 4.5 写的wcf


下一篇:seajs 源码分析四