Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Vladimir Zhelnov - neatek.pw - Web/iOS dev
- let redImage = UIImage(color: .redColor())
- public extension UIImage {
- public convenience init?(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) {
- let rect = CGRect(origin: .zero, size: size)
- UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0)
- color.setFill()
- UIRectFill(rect)
- let image = UIGraphicsGetImageFromCurrentImageContext()
- UIGraphicsEndImageContext()
- guard let cgImage = image?.cgImage else { return nil }
- self.init(cgImage: cgImage)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement