繁体   English   中英

如何在 iOS 中处理 Storyboard ViewControllers?

[英]How to handle Storyboard ViewControllers in iOS?

我在 ViewController 中添加了 3 个视图,如果第二个/中间视图没有文本或者它有一行文本,中间视图的高度应该是 30,最后一个视图应该在运行时向上移动。

在此处输入图片说明

ADD THIS TO YOUR CODE:

CGSize maximumLabelSize = CGSizeMake(296, FLT_MAX);
CGSize expectedLabelSize = [yourString sizeWithFont:yourLabel.font constrainedToSize:maximumLabelSize lineBreakMode:yourLabel.lineBreakMode];   
CGRect newFrame = yourLabel.frame;
newFrame.size.height = expectedLabelSize.height;
yourLabel.frame = newFrame;

添加此代码

[你的标签 sizeToFit ]; 或 [yourView sizeToFit];

暂无
暂无

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

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