我已经使用动态小区大小
CGSize textSize = [text sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:NSLineBreakByWordWrapping];
并返回newHeight
;
来计算表格单元的动态高度。 但在iOS 7中,这不再是。那么iOS 7也有类似的计算单元格或pickerview行高的动态高度。
更新的代码:
NSString * text = str.text;
CGSize constraintSize = CGSizeMake(320.0f, 40.0f); // Make changes in width as per your label requirement.
CGRect textRect = [text boundingRectWithSize:constraintSize
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:[UIFont fontWithName:@"Avenir" size:17]}
context:nil];
CGSize size = textRect.size;
NSLog(@"textSize :: %f",size.height);
return size.height;
我想设置文本的字体大小,我在下面的方法设置选择器视图。
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
NSString *title;
[email protected]"The Grand Bhagvati S G Highway";
return title;
}
可能的重复[在iOS 7中弃用“sizeWithFont:constrainedToSize:lineBreakMode:”我怎么可以替换?](http:// stackoverflow.com/questions/18903304/deprecated-in-ios-7-sizewithfont-constrainedtosize-linebreakmode-how-can) – Amar