UIColor from an image pattern
suggest changeYou can create a UIColor object using an image pattern with the UIColor(patternImage:) initializer. UIImage(named:) is nil when the image is missing, and the force-unwrap below crashes in that case.
btn.backgroundColor = UIColor(patternImage: UIImage(named: "image")!)
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents