2
的UILabel與UIImage的透 - NSAttributedString
我已經研究了很多TTTAttributedLabel等等。
我想下面的代碼,以及
NSString* path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"txt"];
NSString* content = [NSString stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding
error:NULL];
NSMutableAttributedString *s = [[NSMutableAttributedString alloc] initWithString:content];
[s addAttribute:NSBackgroundColorAttributeName
value:[UIColor colorWithPatternImage:[UIImage imageNamed:@"green"]]
range:NSMakeRange(0, s.length)];
_lblTest.attributedText = s;
,並得到了輸出像。
我不需要代碼,但任何人都可以幫助我如何弄清楚它?
它是靜態文本? –
你想達到什麼目的?附圖是它應該是什麼樣子的?或者那是你目前的?另外,當你說你「沒有成功」時,你得到了什麼?試圖找出你想要做的事情,因爲你沒有真正說出你想要發生的事情。 – Fogmeister
@Fogmeister我想要的結果與附圖完全相同。這是一個隨機字符串UIlabel,對於每一行標籤,我都想要這個背景圖片。希望你能找到我。 – kaushik