I'm trying add a image background in my viewController of my Swift app, but colorWithPatternImage is unavailable.. there are other form for this or is necessary add this into a imageView?
I'm trying make this with this code:
let imageName = "image.png"
self.view.backgroundColor = UIColor.colorWithPatternImage(UIImage(named:imageName))
Thanks!
SwiftUI doesn't have a dedicated modifier for displaying background colors or images, but instead lets us specify any kind of background view using its background() modifier. To be clear, you can use any view as your background – another text view if you wanted, for example.
You should use UIColor init method:
view.backgroundColor = UIColor(patternImage: UIImage(named:imageName))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With