```
NSArray * arr = [NSArray arrayWithObjects:@"推送消息",@"系統(tǒng)消息", nil];
self.messageVC = [[UISegmentedControl alloc] initWithItems:arr];
_messageVC.selectedSegmentIndex = 0;//設(shè)置指定索引的題目
_messageVC.layer.cornerRadius = 16 * KY;//圓角
_messageVC.layer.borderColor = [UIColor colorWithHue:0.55 saturation:0.54 brightness:0.86 alpha:1.00].CGColor;//邊框顏色
_messageVC.layer.borderWidth = 1;//邊框?qū)挾?/p>
_messageVC.layer.masksToBounds = YES;//是否剪切
_messageVC.tintColor = [UIColor colorWithHue:0.55 saturation:0.54 brightness:0.86 alpha:1.00];
//默認字體的大小和顏色
NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithHue:0.00 saturation:0.00 brightness:0.43 alpha:1.00],NSForegroundColorAttributeName,[UIFont boldSystemFontOfSize:15],NSFontAttributeName, nil];
[_messageVC setTitleTextAttributes:dic forState:(UIControlStateNormal)];
// 添加監(jiān)聽
[_messageVC addTarget:self action:@selector(didClickSegmentedControlAction:)forControlEvents:UIControlEventValueChanged];
/**
*? 監(jiān)聽點擊了哪項
*/
- (void)didClickSegmentedControlAction:(UISegmentedControl *)segmentControl
{
NSInteger idx = segmentControl.selectedSegmentIndex;
NSLog(@"%ld", idx);
}