2014-03-28 24 views
9

UILabel末尾的虛線不受textColor的影響。iOS 7.1中的UILabel虛線顏色錯誤

你會在這裏找到一個示例項目:https://github.com/nverinaud/DottedLineBug

所涉及的代碼如下:

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

下面是一個圖片放映的問題: enter image description here

有沒有人有同樣的錯誤,有找到一個解決辦法?

謝謝!

+0

你試過使用NSAttributedString嗎? – Andrea

+3

而不是發佈一個鏈接到您的項目,通過粘貼相關的代碼來更新您的問題。只需發佈標籤和顏色的代碼。 – rmaddy

+0

你應該完全按照Andrea的說法 – Zarkus13

回答

8

使用NSAttributedString確實有效。 (感謝Andrea)。

這裏是個例:

- (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; 
} 

我做了報告,蘋果,這裏是報告ID:16470528

它已被Apple標記爲16443091的副本。