how to set a background image as colorWithPatternImage in swift

后端 未结 7 705
心在旅途
心在旅途 2020-12-23 11:10

My questions is, is it possible to have a UIView display an image, and if so, how so I do it? All I can find is the colorwithpatternImage which no longer works

7条回答
  •  难免孤独
    2020-12-23 11:55

    Edited @User9527 's answer a bit. Not sure why it was down voted.. Worked great for me. Just added my own custom frame.

    let frame = CGRectMake(10, 55, 45, 45)
    let backgroundImage = UIImageView(frame: frame)
    backgroundImage.image = UIImage(named: "bg_image")
    self.view.insertSubview(backgroundImage, atIndex: 0)
    

提交回复
热议问题