0
我怎樣才能在iOS的5.1這樣的 -的iOS attributedText 5.1
NSString *statusStrColored = [NSString stringWithFormat:@"%@ (%@)", statusStr, paymentStatusStr];
NSLog(@"stoka = %@", statusStrColored);
//NSArray *components = [statusStrColored componentsSeparatedByString:@" "];
NSRange greenRange = [statusStrColored rangeOfString:statusStr];
NSRange redRange = [statusStrColored rangeOfString:paymentStatusStr];
NSMutableAttributedString *attrString1 = [[NSMutableAttributedString alloc] initWithString:statusStrColored];
[attrString1 beginEditing];
[attrString1 addAttribute: (NSString*)kCTForegroundColorAttributeName
value:(id)[[UIColor greenColor] CGColor]
range:greenRange];
[attrString1 addAttribute: (NSString*)kCTForegroundColorAttributeName
value:(id)[[UIColor redColor] CGColor]
range:redRange];
[attrString1 endEditing];
cell.textLabel.attributedText = attrString1;
在iOS 6中的好,但在5.1 ...這不可用(((
,我有錯誤對碼 -
cell.textLabel.attributedText = attrString1;
它可能已在模擬的iOS在使用DTCoreText的向後兼容ATTR 5.1
可能是這個 - https://github.com/AliSoftware/OHAttributedLabel ??? – Nubaslon
** [This may help you。](http://stackoverflow.com/questions/3586871/bold-non-bold-text-in-a-single-uilabel)** – Hemang