-1

我試圖爲我的某些標籤添加刪除線。 我的項目支持32位和64位。 在iOS 8上一切正常,但在iPhone 5c上的iOS 7上,標籤消失。 這是我的代碼:添加屬性文本隱藏UILabel

NSMutableAttributedString *throughLineAttributeString = [[NSMutableAttributedString alloc] initWithString:label.text]; 
    [throughLineAttributeString addAttribute:NSStrikethroughStyleAttributeName 
             value:@1 
             range:NSMakeRange(0, [throughLineAttributeString length])]; 
label.attributedText = throughLineAttributeString; 

我在做什麼錯?

+0

添加label.layer.borderWidth = 3;並檢查,它消失了還是隻是什麼都沒有顯示 – mityaika07 2014-12-03 11:50:14

+1

是的標籤仍然存在於同一幀。似乎只是文本丟失。 – YogevSitton 2014-12-03 12:34:19

+0

ok,設置label.layer.masksToBounds = NO,並檢查文本位置 – mityaika07 2014-12-03 12:36:13

回答

-1

嘗試改變:

NSMutableAttributedString *throughLineAttributeString = [[NSMutableAttributedString alloc] initWithString:label.text]; 

到:

NSMutableAttributedString *throughLineAttributeString = [[NSMutableAttributedString alloc] initWithAttributedString:label.attributedText]; 
+0

此時標籤沒有屬性文本。它只有文本。 – YogevSitton 2014-12-03 13:16:07