Skip to content

Instantly share code, notes, and snippets.

@gtempesta
Created October 10, 2016 13:30
Show Gist options
  • Save gtempesta/f3a478b6350ca6012dff9e333426fc74 to your computer and use it in GitHub Desktop.
Save gtempesta/f3a478b6350ca6012dff9e333426fc74 to your computer and use it in GitHub Desktop.
Easiest way to draw a Circle in swift 3.0
import UIKit
import XCPlayground
import PlaygroundSupport
public class SimpleLine: UIView {
public init() {
super.init(frame: CGRect(x: 0, y: 0, width: 480, height: 320))
backgroundColor = UIColor.white
}
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public override func draw(_ rect: CGRect) {
let context = UIGraphicsGetCurrentContext()
let boundingRect = CGRect(x: 220, y: 100, width: 80, height: 80)
context!.setLineWidth(4.0)
context!.setStrokeColor(UIColor.black.cgColor)
context!.setFillColor(UIColor.darkGray.cgColor)
context!.fillEllipse(in: boundingRect)
context!.strokeEllipse(in: boundingRect)
}
}
let firstLine = SimpleLine()
PlaygroundPage.current.liveView = firstLine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment