簡體   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