在現場有一個iPhone 4和一個奇怪的問題,UILabel不顯示任何文本。我在iPhone 4S + iOS 7模擬器上測試了它,它工作正常。UILabel.attributedText不顯示在iPhone 4 + iOS 7.0.3上
代碼:
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:[colLabel.text copy]];
[attributeString addAttribute:NSUnderlineStyleAttributeName
value:[NSNumber numberWithInt:1]
range:(NSRange){0,[attributeString length]}];
colLabel.text = nil;
colLabel.attributedText = [attributeString copy];
colLabel.font = [UIFont boldSystemFontOfSize:12];
請參考以下鏈接: - http://stackoverflow.com/questions/19127828/ios-7-bug-nsattributedstring-does-not-appear http://stackoverflow.com/questions/3482346/how-do-you-use-nsattributedstring – poojathorat
上面的代碼在大多數情況下工作正常。在iPhone 4上用NSUnderlineStyleAttributeName奇怪。我試圖刪除底線屬性,它可以繪製。一旦加回來,不再工作。所以這是NSUnderlineStyleAttributeName問題。而且,你的鏈接不能解決我的問題。 – Wingzero
想通了!上帝大壩* iPhone 4在7.0.2上,只是越野車而已。 – Wingzero