2016-05-20 22 views
1


我有一個自定義的UITableViewCell裏面有一個標籤,自動佈局設置正確。我想設置屬性文本是這樣的:
UILabel中的空白 - 來自HTML的屬性文本集

dataString = [dataString stringByAppendingString:[NSString stringWithFormat:@"<style>body{font-family: 'RobotoCondensed-Regular'; font-size:11px;}</style>"]]; 
NSMutableAttributedString * attrStr = [[NSMutableAttributedString alloc] initWithData:[dataString dataUsingEncoding:NSUTF8StringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding] } documentAttributes:nil error:nil]; 
_scheduleLabel.attributedText = attrStr; 

dataString是<p>L-D: <b>10-22</b></p> 的tableview中有UITableViewAutomaticDimension,問題是,標籤具有文本之後多餘的空白,它打亂了整個佈局。爲什麼會發生這種情況,我該如何刪除它? enter image description here

回答

0

它發生在我身上。我的解決方案是用和替換html中的

標籤,並且它刪除了空格。