Ios7 uisegmentedcontrol的边框颜色

Ios7 uisegmentedcontrol的边框颜色,ios7,uisegmentedcontrol,Ios7,Uisegmentedcontrol,在iOS7中更改分段控件的边框颜色时遇到问题。我在stackoverflow的其他地方发现了以下建议: [[UISegmentedControl appearance] setTitleTextAttributes:@{ UITextAttributeTextColor: [UIColor colorWithRed:255.0/255.0 green:255.0/25

在iOS7中更改分段控件的边框颜色时遇到问题。我在stackoverflow的其他地方发现了以下建议:

    [[UISegmentedControl appearance] setTitleTextAttributes:@{
                                                             UITextAttributeTextColor: [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],
                                                             UITextAttributeTextShadowColor: [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0],
                                                             UITextAttributeFont: [UIFont fontWithName:@"Arial-Bold" size:0.0],
                                                             NSForegroundColorAttributeName : [UIColor redColor],

                                                             } forState:UIControlStateSelected];

    [self.segmentedControl setTitleTextAttributes:@{
                                                    UITextAttributeTextColor: [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],
                                                    UITextAttributeTextShadowColor: [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0],
                                                    UITextAttributeFont: [UIFont fontWithName:@"Arial-Bold" size:0.0],
                                                    NSForegroundColorAttributeName : [UIColor redColor],

                                                    } forState:UIControlStateNormal];
但在这两种情况下,我的边界仍然是蓝色。我似乎无法通过settitleTextAttributes更改字体阴影、边框颜色或其他任何内容


如何调整边框颜色?

好的,我太费劲了。所以我做了一个工作。我最终只是创建了一个新的UILabel,并将其作为子视图添加到分段控制器中的每个项目中

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    NSArray * segments = @[@"Crop",@"Nutrient",@"Product Group"];

    [self.segmentedControl setBackgroundImage:[UIImage imageNamed:@"background-yellowgradient.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

    [self.segmentedControl setSegmentedControlStyle:UISegmentedControlStyleBar];
    for (int i=0; i<[self.segmentedControl.subviews count]; i++)
    {

        [[self.segmentedControl.subviews objectAtIndex:i] setTintColor:[UIColor clearColor]];
        UILabel *l = [[UILabel alloc] init];
        l.text = [segments objectAtIndex:i];
        l.textColor = [UIColor whiteColor];
        l.textAlignment = NSTextAlignmentCenter;
        l.adjustsFontSizeToFitWidth = NO;
        l.font = [UIFont systemFontOfSize:12];


        CGRect  f = [[self.segmentedControl.subviews objectAtIndex:0] frame];
        f.size.width = self.segmentedControl.frame.size.width/3;
        f.size.height = self.segmentedControl.frame.size.height;
        f.origin.x = 0;
        f.origin.y = 0;

        l.frame = f;

        [[[self.segmentedControl subviews] objectAtIndex:i] addSubview:l];

    }
}
else{
    // if it's not IOS7, then do what i was doing before for ios6.1 and below
}
if([[[UIDevice currentDevice]systemVersion]floatValue]>=7){
NSArray*细分市场=@[@“作物”、@“营养素”、@“产品组”];
[self.segmentedControl setBackgroundImage:[UIImage ImageName:@“background yellowgradient.png”]用于状态:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[self.segmentedcontrolsetSegmentedControlStyle:UISegmentedControlStyleBar];
对于(int i=0;i
[segmentControlObj setTintColor:[UIColor redColor]];