Skip to content

Instantly share code, notes, and snippets.

@quangtqag
Created February 26, 2019 02:13
Show Gist options
  • Save quangtqag/ff03b82e19520267854e189cdbbd5972 to your computer and use it in GitHub Desktop.
Save quangtqag/ff03b82e19520267854e189cdbbd5972 to your computer and use it in GitHub Desktop.
class ViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let renderer = UIGraphicsImageRenderer(size: CGSize(width: 200, height: 200))
let image = renderer.image { (context) in
UIColor.darkGray.setStroke()
context.stroke(renderer.format.bounds)
UIColor(displayP3Red: 158/255, green: 215/255, blue: 245/255, alpha: 1).setFill()
context.fill(CGRect(x: 1, y: 1, width: 140, height: 140))
UIColor(displayP3Red: 145/255, green: 211/255, blue: 205/255, alpha: 1).setFill()
context.fill(CGRect(x: 60, y: 60, width: 140, height: 140), blendMode: .multiply)
UIColor(displayP3Red: 203/255, green: 222/255, blue: 116/255, alpha: 0.6).setFill()
context.cgContext.fillEllipse(in: CGRect(x: 60, y: 60, width: 140, height: 140))
}
self.imageView.image = image
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment