Home  >  Q&A  >  body text

ios - storyboard中设置layout, 能不能设置空间的宽度为屏幕宽度的百分比?

我在storyboard中设置layout,假如我设置了button, 水平居中,我可不可以设置button的宽度为屏幕宽度的百分比?

伊谢尔伦伊谢尔伦2729 days ago758

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 15:21:57

    Select the button and click control to connect to viewController.view, which is the view with the usual screen width

    Select

    Then click Size inspector->Constraints to find the corresponding item, click Edit, and adjust the multiplier

    reply
    0
  • 迷茫

    迷茫2017-04-17 15:21:57

    This is possible, but the setting is not the ratio to the screen, but the ratio to Superview. UIViewController.view.width Equivalent to screen width.
    Because there are a lot of steps, I wrote an article specifically. Storyboard usage tips: Use proportional layout

    reply
    0
  • Cancelreply