设置选中未选中时的效果,很简单,一目了然
NSArray *array = @[@"第一组",@"第二组"];
segmentC = [[UISegmentedControl alloc]initWithItems:array];
[segmentC addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];
segmentC.tintColor = [UIColor clearColor];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Heiti SC" size:13],NSFontAttributeName,[UIColor lightGrayColor], NSForegroundColorAttributeName, nil];
[segmentC setTitleTextAttributes:attributes forState:UIControlStateNormal];
NSDictionary *highlightedAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Heiti SC" size:15],NSFontAttributeName,backTextColor, NSForegroundColorAttributeName, nil];
[segmentC setTitleTextAttributes:highlightedAttributes forState:UIControlStateSelected];
segmentC.selectedSegmentIndex = 0;
[self.view addSubview:segmentC];