0
我有兩個標籤,並使用一個歸屬字符串設置backgroundColor。使用backgroundcolor將標籤字符串設置爲標籤
NSString *string = @"This is a UILAbel with two lines";
NSMutableAttributedString *mutableString = [[NSMutableAttributedString alloc]initWithString:
string];
[mutableString setAttributes:@{NSBackgroundColorAttributeName : [UIColor redColor]} range:NSMakeRange(0, string.length)];
如果文本產生換行符,則將backgroundColor填充到右邊框,在第二行中它將停在最後一個字符處。
但我想第一行中的backgroundcolor也設置爲最後一個字符。
你可以顯示你的問題或你想要的圖像。 –
你是如何得到正確的照片? –
您正在將背景顏色設置爲紅色...對我來說看起來很漂亮:p –