search

Home  >  Q&A  >  body text

ios - 跳转到xib时,怎样让xib自适应屏幕的大小?

加载xib时,怎样让view自适应屏幕的大小?

巴扎黑巴扎黑2773 days ago817

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-17 13:52:08

    The method is to add constraints (autolayout)

    Here is an example, the steps are as follows:
    1) The podfile file of cocoaPod is as follows

    2) StoryBoard adds subview View1 as follows

    3) The xib to be loaded is as follows

    4) The viewcontroller loads the XIB onto a view and constrains its size. The code is as follows:

    5) The running results are as follows

    Supplement: If you want to adapt to the screen size, just change self.View1 to self.view in the 4) code accordingly~
    Also, what does jumping to XIB mean? Does it mean loading? Please describe the topic as clearly as possible so that others can help you. .

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 13:52:08

    You can check information about AutoLayout

    reply
    0
  • Cancelreply