【问题标题】:UIButton width is 50% of UIView's width iOSUIButton 宽度是 UIView 宽度的 50% iOS
【发布时间】:2015-03-18 07:26:49
【问题描述】:

我是 Storyboard 环境的新手。

如何在 XCode6 的 Storyboard 中使用 AutoLayout Constraints 将 UIButton's 宽度设置为 UIView's 宽度的 50%

谁能告诉我如何实现这个?

【问题讨论】:

  • 使用 align & pin 约束,取宽度为百分比
  • 点击按钮,按住control键拖到视图,选择等宽,然后修改约束的纵横比为1:0.5。
  • 感谢 gabbler 现在正在工作

标签: ios uiview uibutton storyboard xcode6


【解决方案1】:
  1. 选择你的按钮和超级视图

  1. 制作别针

  1. 选择约束

  1. 颠倒这两个项目并将乘数设置为 0.5

  1. 仅选择按钮并设置水平对齐

完成!

我推荐使用来自 github 的 Masonry/SnapKit 库

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-09
    • 1970-01-01
    • 2014-10-01
    • 2019-07-29
    • 1970-01-01
    • 2015-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多