Próbuję zmierzyć wizualny rozmiar NSString, który bierze pod uwagę liczbę linii, które mogę renderować. Jednak sizeWithFont nie uwzględnia właściwości numberOfLines? Tak więc mój algorytm układania pozycjonuje wszystko, co jest niższe, niż musi być.iPhone UILabel sizeWithFont:
_price = [[UILabel alloc] init];
_price.text = myPriceValue;
_price.lineBreakMode = UILineBreakModeWordWrap;
_price.numberOfLines = 3;
_price.backgroundColor = [UIColor clearColor];
_price.textColor = TTSTYLEVAR(colorPrice);
/// the follow code ignores numberOfLines and just tells me the size of the whole block.
// I'd like it to be aware of numberOfLines
//
CGSize priceSize = [_price.text sizeWithFont:_price.font
constrainedToSize:CGSizeMake(maxWidth, CGFLOAT_MAX)
lineBreakMode:UILineBreakModeWordWrap];
Czy ktoś wie, jak to zrobić, korzystając z iPhone SDK?
sizeWithFont jest przestarzałe w iOS7 i zamiast tego należy użyć boundingReadWithSize. –