I\'m working on an application, in which I\'m required to autoresize the text area on basis of text to be displayed.
Firstly, I\'m not sure for this either I should use
If you want to resize the UILabel only in height, use this:
@property (nonatomic, weak) IBOutlet UILabel *titleLabel;
CGRect titleLabelBounds = self.titleLabel.bounds;
titleLabelBounds.size.height = CGFLOAT_MAX;
// Change limitedToNumberOfLines to your preferred limit (0 for no limit)
CGRect minimumTextRect = [self.titleLabel textRectForBounds:titleLabelBounds limitedToNumberOfLines:2];
CGFloat titleLabelHeightDelta = minimumTextRect.size.height - self.titleLabel.frame.size.height;
CGRect titleFrame = self.titleLabel.frame;
titleFrame.size.height += titleLabelHeightDelta;
self.titleLabel.frame = titleFrame;
Now you can use titleLabelHeightDelta
to layout other views depending on your label size (without using autolayout).