简体   繁体   中英

How can TTStyledTextLabel change width/height on orientation changes?

I think I am stuck. How can you make a TTStyledTextLabel to expand to the available width/height?

I've seen on the UILabel that you can do it by doing something along these lines:

CGSize captionSize = [_label.text sizeWithFont:_label.font 
                             constrainedToSize:CGSizeMake(maxWidth, CGFLOAT_MAX)
                                 lineBreakMode:UILineBreakModeWordWrap];

_label.frame =  CGRectMake(boundsX + 90 , 40, captionSize.width, captionSize.height);

How can you do the same with a TTStyledTextLabel?

Try setting the autoresizing mask. To pin the left and right bounds relative to the superview and have it stretch the width to fit the space in between, you would use:

[label setAutoresizingMask:UIViewAutoresizingMaskFlexibleWidth];

The autoresizing mask is supported by every UIView . Superviews and their view controllers can also take a more active hand in resizing their subviews using -[UIView layoutSubviews] and -[UIViewController viewDidLayoutSubviews] .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM