如何在故事板上为xcode中的所有设备定位按钮

时间:2021-07-13 22:50:31

I'm trying to place these buttons that are responsive for all the devices. Can someone please help me? I've been trying this but never worked. attached screen shot for what i'm looking- 如何在故事板上为xcode中的所有设备定位按钮Thanks in advance

我正在尝试放置对所有设备都有响应的按钮。有人可以帮帮我吗?我一直在尝试这个但从未奏效。为我正在寻找的附加屏幕拍摄 - 提前谢谢

1 个解决方案

#1


1  

I would try these constraints. You can adjust the constant values to get the look you want:

我会尝试这些约束。您可以调整常量值以获得所需的外观:

Top button:

  1. Button.Leading equal to Superview.Leading.
  2. Button.Leading等于Superview.Leading。

  3. Button.Top equal to Top Layout Guide.Bottom with constant 25.
  4. Button.Top等于Top Layout Guide.Bottom,常量为25。

  5. Superview.Trailing equal to Button.Trailing with constant 70.
  6. Superview.Trailing等于Button.Trailing,常数为70。

  7. Button.Height equal to constant 140.
  8. Button.Height等于常数140。

Middle button:

  1. Button.Leading equal to Superview.Leading with constant 70.
  2. Button.Leading等于Superview.Leading与常量70。

  3. Button.Top equal to FirstButton.Bottom with constant 35.
  4. Button.Top等于FirstButton.Bottom,常数为35。

  5. Superview.Trailing equal to Button.Trailing.
  6. Superview.Trailing等于Button.Trailing。

Bottom button:

  1. Button.Leading equal to Superview.Leading.
  2. Button.Leading等于Superview.Leading。

  3. Button.Top equal to SecondButton.Bottom with constant 35.
  4. Button.Top等于SecondButton.Bottom,常量为35。

  5. Superview.Trailing equal to Button.Trailing with constant 70.
  6. Superview.Trailing等于Button.Trailing,常数为70。

  7. Bottom Layout Guide.Top equal to Button.Bottom with constant 45.
  8. 底部布局指南。顶部等于Button.Bottom,常量为45。

  9. Button.Height equal to constant 140.
  10. Button.Height等于常数140。

This will allow the middle button to grow in height on larger devices, and all buttons will grow in width on larger devices.

这将允许中间按钮在较大的设备上增加高度,并且所有按钮将在较大的设备上增加宽度。

#1


1  

I would try these constraints. You can adjust the constant values to get the look you want:

我会尝试这些约束。您可以调整常量值以获得所需的外观:

Top button:

  1. Button.Leading equal to Superview.Leading.
  2. Button.Leading等于Superview.Leading。

  3. Button.Top equal to Top Layout Guide.Bottom with constant 25.
  4. Button.Top等于Top Layout Guide.Bottom,常量为25。

  5. Superview.Trailing equal to Button.Trailing with constant 70.
  6. Superview.Trailing等于Button.Trailing,常数为70。

  7. Button.Height equal to constant 140.
  8. Button.Height等于常数140。

Middle button:

  1. Button.Leading equal to Superview.Leading with constant 70.
  2. Button.Leading等于Superview.Leading与常量70。

  3. Button.Top equal to FirstButton.Bottom with constant 35.
  4. Button.Top等于FirstButton.Bottom,常数为35。

  5. Superview.Trailing equal to Button.Trailing.
  6. Superview.Trailing等于Button.Trailing。

Bottom button:

  1. Button.Leading equal to Superview.Leading.
  2. Button.Leading等于Superview.Leading。

  3. Button.Top equal to SecondButton.Bottom with constant 35.
  4. Button.Top等于SecondButton.Bottom,常量为35。

  5. Superview.Trailing equal to Button.Trailing with constant 70.
  6. Superview.Trailing等于Button.Trailing,常数为70。

  7. Bottom Layout Guide.Top equal to Button.Bottom with constant 45.
  8. 底部布局指南。顶部等于Button.Bottom,常量为45。

  9. Button.Height equal to constant 140.
  10. Button.Height等于常数140。

This will allow the middle button to grow in height on larger devices, and all buttons will grow in width on larger devices.

这将允许中间按钮在较大的设备上增加高度,并且所有按钮将在较大的设备上增加宽度。