How to add image in background in my opinion in swift?

I am trying to add an image background to my viewController of my Swift application, but colorWithPatternImage is not available. Is there any other form for this or is it necessary to add this to imageView?

I am trying to do this with this code:

let imageName = "image.png" self.view.backgroundColor = UIColor.colorWithPatternImage(UIImage(named:imageName)) 

Thanks!

+6
source share
1 answer

You should use the UIColor initialization method:

 view.backgroundColor = UIColor(patternImage: UIImage(named:imageName)) 
+14
source

Source: https://habr.com/ru/post/972819/


All Articles