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

前端 未结 9 2126
刺人心
刺人心 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:59

    This uses PureLayout. You could just use AutoLayout with a few more lines.

    UIImageView* imgView = UIImageView(image: myUIImage)
    imgView.setTranslatesAutoresizingMaskIntoConstraints(false)
    self.view.addSubview(imgView)
    self.view.addConstraints(imgView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsMake(0,0,0,0))
    

提交回复
热议问题