Xcode 6: How to make an image view fill the screen on all devices? Auto layout not working?

后端 未结 4 1549
孤独总比滥情好
孤独总比滥情好 2020-12-22 22:27

So I have an image view and a button. I need the image view to be the correct size (not look squished or stretched) on all devices and more importantly I need it to be the s

4条回答
  •  暖寄归人
    2020-12-22 23:26

    This is what worked for me:

    View Mode:
    Aspect Fill

    As constraints for the image:
    Align Center X to: Superview
    Equal width to: Superview

    The 'Equal width' property is the one that scale the image to the size of the screen.

    If you want to have the button in a specific position, set constraints from it to the view, the main ones you want to consider are a top constraint and any left or right constraints. So you are telling the view where you want to position the button in relation to its sides.

    Hope this helps.

提交回复
热议问题