简体   繁体   English

如何在 iOS 中处理 Storyboard ViewControllers?

[英]How to handle Storyboard ViewControllers in iOS?

I have added 3 Views in ViewController, if 2nd/middle view has no text or it has one line text, the height of the middle view should be 30 and last view should move up at run time.我在 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;

ADD this CODE添加此代码

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

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

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