Finding the number of lines(Height) to make a UITextfield & Cell
As I get string开发者_运维百科s of text down from my database, I need to know how big to make the UITextField and how big to make the Cell of the table that contains the UITextfield.
Are there any clever methods that can determine this? Since it will of course depend on the textfield width and the font used.
Thanks -Code
NSString
has a method sizeWithFont:contrainedToSize:
that will give you to the size of a string with a particular font:
UIFont *font = [UIFont systemFontOfSize:12.f];
CGSize size = CGSizeMake(textView.frame.size.width, 1000.f);
CGSize stringSize = [myString sizeWithFont:font constrainedToSize:size];
精彩评论