I have a non-scrollable UITextView with it\'s layoutManager maximumNumberOfLines set to 9, which works fine, but, I cannot seem to find a method in NSLayoutManager that rest
You will need to do this yourself. Basically it would work like this:
UITextViewDelegate
's textView:shouldChangeTextInRange:replacementText:
method find the size of your current text (NSString sizeWithFont:constrainedToSize:
for example).EDIT: Since sizeWithFont:
is deprecated use boundingRectWithSize:options:attributes:context:
Example:
NSString *string = @"Hello World";
UIFont *font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:21];
CGSize constraint = CGSizeMake(300,NSUIntegerMax);
NSDictionary *attributes = @{NSFontAttributeName: font};
CGRect rect = [string boundingRectWithSize:constraint
options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading)
attributes:attributes
context:nil];