Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UILabel dotted line color bug in iOS 7.1

Tags:

ios

uilabel

The dotted line at the end of an UILabel is not affected by the textColor.

You will find a sample project here : https://github.com/nverinaud/DottedLineBug.

The code involved is the following :

- (IBAction)sliderValueChanged:(UISlider *)sender
{
    UIColor *color = [UIColor colorWithHue:sender.value
                                saturation:1
                                brightness:1
                                     alpha:1];
    self.label.textColor = color;
}

Here is a picture showing the issue : enter image description here

Does anyone have the same bug and have find a workaround ?

Thanks !

like image 772
nverinaud Avatar asked Mar 28 '14 16:03

nverinaud


1 Answers

Using NSAttributedString does work. (Thanks to Andrea).

Here is an exemple :

- (IBAction)sliderValueChanged:(UISlider *)sender
{
    UIColor *color = [UIColor colorWithHue:sender.value
                                saturation:1
                                brightness:1
                                     alpha:1];

    NSAttributedString *text = [[NSAttributedString alloc] initWithString:self.text attributes:@{ NSForegroundColorAttributeName : color }];

    self.label.attributedText = text;
}

I did report to Apple, here is the report ID : 16470528.

It has already been marked by Apple as a duplicate of 16443091.

like image 160
nverinaud Avatar answered Nov 10 '22 12:11

nverinaud