我正在調整表的cell
和UILabel
。標籤似乎被調整大小,但仍然在一行上。如何處理這個?調整UILabel不太正常
的標籤從故事板設置爲:
Line Breaks: Word Wrap;
Autoshrink: Fixed Font Size;
Lines: 0
CGRect textRect = [cell.sampleLabel.text boundingRectWithSize:boundingSize options:NSStringDrawingUsesLineFragmentOrigin attributes: @{NSFontAttributeName:cell.sampleLabel.font} context:nil];
NSLog(@"textRect height: %f", textRect.size.height);
cell.sampleLabel.frame = textRect;
NSLog(@"label height: %f", cell.sampleLabel.frame.size.height);
的NSLog
:
2013-12-20 11:04:41.623 DevCloud[16613:70b] textRect height: 223.091019
2013-12-20 11:04:41.624 DevCloud[16613:70b] label height: 224.000000
2013-12-20 11:04:41.626 DevCloud[16613:70b] textRect height: 223.091019
2013-12-20 11:04:41.627 DevCloud[16613:70b] label height: 224.000000
不相關的Xcode 5這只是一個IDE。 – Raptor
是否可以用動態高度創建標籤? –