How do you make a background image scale to screen size in swift?

前端 未结 9 2089
刺人心
刺人心 2020-11-27 04:27

I\'m trying to make a UIView image for my background in swift using pattern image. The code I have works well except for the fact that I want the image to take the whole scr

9条回答
  •  北海茫月
    2020-11-27 04:49

    Just add your UIImageView positioned centered and with all edges snapping to the edges. Leave it there and click on the right bottom corner as shown below and now go ahead and add 4 constrains to Top, Bottom, Left and Right Edges.

    enter image description here

    Now just select your image view and using the IB inspector select how you would like your image: fill or fit as you can see as follow:

    enter image description here

提交回复
热议问题