UISegmentedControl简单使用

@property (nonatomic, strong) UISegmentedControl *segmented;
- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationItem.titleView = self.segmented;

}
- (UISegmentedControl *)segmented{
    if (!_segmented) {
        _segmented = [[UISegmentedControl alloc]initWithItems:@[@"我的宣教课程",@"本院宣教课程"]];
        _segmented.selectedSegmentIndex = 0;//设置默认选中第几个
        _segmented.tintColor = kBlueColor;//设置segmented颜色
        _segmented.frame = CGRectMake(0, 0, 220, 30);
        [_segmented addTarget:self action:@selector(missionCourseChangeEvent:) forControlEvents:UIControlEventValueChanged];
    }
    return _segmented;
}
UISegmentedControl简单使用_第1张图片
segmented.gif

你可能感兴趣的:(UISegmentedControl简单使用)