简体   繁体   English

TTStyledTextLabel如何在方向更改时更改宽度/高度?

[英]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? 如何使TTStyledTextLabel扩展到可用的宽度/高度?

I've seen on the UILabel that you can do it by doing something along these lines: 我已经在UILabel上看到可以通过按照以下方式进行操作来做到这一点:

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? 如何使用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 . 每个UIView支持自动调整大小掩码。 Superviews and their view controllers can also take a more active hand in resizing their subviews using -[UIView layoutSubviews] and -[UIViewController viewDidLayoutSubviews] . 超级视图及其视图控制器还可以使用-[UIView layoutSubviews]-[UIViewController viewDidLayoutSubviews]更加积极地调整其子视图的大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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