2016-10-02 33 views
1

由於某些原因,我真的很難與約束條件糾纏在一起。我試圖讓這個對象在中間展開。在第一個圖像多數民衆贊成我想要它看起來像所有設備上。我需要什麼約束,因此其應用可以根據設備Xcode 8中的限制 - 根據設備將對象放大

enter image description here

enter image description here

enter image description here

+0

你現在用什麼約束?您可能只需要一個沒有寬度限制的前導/尾隨,因爲寬度可以「神奇」地調整到任何寬度。 – BHendricks

+0

目前沒有使用,因爲我不知道如何實現我想要做的。我會嘗試領先/尾隨。 –

+0

是的,所以一般來說,你會想要4個約束條件,以及你想要做什麼,看起來像你想要的:頂部/高度/領先/尾隨。您通常在自動佈局世界中希望遠離「硬編碼」的寬度/高度,但取決於UI組件... – BHendricks

回答

0
從您的評論

這樣的規模擴大,你有視圖結構,它是將很難保持「與文本標籤相同的距離」。

我建議這樣的:

UIView (root view for this view) 

    UIImageView (your overlay, which should have top/bottom/left/right constraints to edges) 

    UIView (a container view, which will hold the label and arrow image. This should have, as we discussed, top/height/left/right constraints) 

     UILabel (label for your text, centered horizontally within it's superview container, as well as vertically) 

     UIImageView (arrow, with a leading constraint pinned to the right of the label, and with centered vertically constraint to it's superview) 

這應該實現你後是什麼,我相信。另外,當我說左/右,這是領先/尾隨的代名詞。

+1

謝謝!完美的作品。再次感謝Xcode中對約束的更多的瞭解。 –