search

Home  >  Q&A  >  body text

ios - xib约束问题,求解决!!!


问:
1.如何让模块定位在xib的view上面的25%的位置?只能用代码来约束吗???
2.xib的视图的宽度是320,如果添加到6p上面,怎样才能做到适配屏幕的全宽度?也是只能用用代码来约束吗???

高洛峰高洛峰2887 days ago382

reply all(4)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 17:44:20

    It can be completed with just one constraint and can be adapted to any screen size. Other constraints are designed to allow the control to change proportionally, and can also be set to fixed.

    reply
    0
  • 阿神

    阿神2017-04-17 17:44:20

    For xib, use Aspect Ratio to set the height ratio, which means the layout is a little rounded, and autolayout and size class are used to automatically adapt to the full screen.
    If you use code constraints, it is recommended to use some better layout frameworks such as Masonry, which is very convenient .

    reply
    0
  • PHPz

    PHPz2017-04-17 17:44:20

    First of all, I have been thinking about these issues recently, so I paid attention to this.

    Based on your question, I can give you a general direction, that is, when performing autoLayout on xib, you can select the proportion. Using this method, you can completely achieve the effect you want to achieve. As for the specific implementation method, I'm still researching.

    I wish you can solve it as soon as possible and share it with me later

    reply
    0
  • PHPz

    PHPz2017-04-17 17:44:20

    Try Aspect Ratio.

    reply
    0
  • Cancelreply