I have a UILabel that I want to expand vertically rather than horizontally after some maximumWidth. Currently I am trying to do this by doing the following:
_caption.numberOfLines = 0;
_caption.lineBreakMode = NSLineBreakByWordWrapping;
and then when I size I use sizeToFit
However, I always have a width that is much larger than my maximumWidth.
I tried using preferredMaxLayoutWidth
but this did not work.
I could do a simple calculation by dividing the width by the maximumWidth that I want and then adjust the height accordingly but I'm wondering if there is any way to do this automatically.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.