how to set a background image as colorWithPatternImage in swift

后端 未结 7 666
心在旅途
心在旅途 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 12:11

    You have to add optional binding for the above code to work. That is exclamation after UIImage as shown below.

    view.backgroundColor = UIColor(patternImage: UIImage(named: "backgroundSection.png")!)

提交回复
热议问题