This question is more for development purposes and would never be used for a shipping app. I need to do a quick and dirty UILabel whose text field I can point to a really, really, long string. Really long. I've ben futzing in IB and can't figure out the correct magic handshake to allow a UILabel to balloon to a really large size. Does anyone have any ideas?
Cheers, Doug
You can use a method in the UIKit additions to NSString to achieve this. You can get the size using this method:
- (CGSize)sizeWithFont:(UIFont *)font
minFontSize:(CGFloat)minFontSize
actualFontSize:(CGFloat *)actualFontSize
forWidth:(CGFloat)width
lineBreakMode:(UILineBreakMode)lineBreakMode
Set the size of the label to the return value of this method and you're all set.
EDIT: That method is for one-line strings. If your string is more than one line, use this method:
- (CGSize)sizeWithFont:(UIFont *)font
constrainedToSize:(CGSize)size
lineBreakMode:(UILineBreakMode)lineBreakMode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With