//创建 self.segmented =[[UISegmentedControl alloc]initWithItems:@[@"推荐阅读",@"我的订阅"]]; //设置大小 _segmented.frame = CGRectMake(0.0, 0.0, 200, 30.0); //设置默认选中 _segmented.selectedSegmentIndex=0; //设置颜色 _segmented.tintColor = [UIColor grayColor]; //添加事件 [_segmented addTarget:self action:@selector(changeView:) forControlEvents:UIControlEventValueChanged]; [self.navigationItem setTitleView:_segmented];