SegmentController

NSArray *array = [NSArray arrayWithObjects:@”職位詳情”,@”公司信息”, nil];
_segmentControl = [[UISegmentedControl alloc] initWithItems:array];
_segmentControl.frame = CGRectMake(0, 0, 170, 30);
_segmentControl.frame = [GeneralUIFactory autoLayout:_segmentControl];
_segmentControl.tintColor = [UIColor whiteColor];
_segmentControl.selectedSegmentIndex = 0;
NSDictionary* selectedTextAttributes = @{NSFontAttributeName:[UIFont setFontSize:13],NSForegroundColorAttributeName:[UIColor getColor:@”#14aae0”]};
[_segmentControl setTitleTextAttributes:selectedTextAttributes forState:UIControlStateSelected];

NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont setFontSize:13],NSForegroundColorAttributeName: [UIColor whiteColor]};
[_segmentControl setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal];

[_segmentControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
self.navigationItem.titleView = _segmentControl;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章