iOS UIColor from an image pattern


Example

You can create a UIColor object using an image pattern by using the UIColor(patternImage:_) method.

btn.backgroundColor = UIColor(patternImage: UIImage(named: "image")!)

enter image description here