Created
October 10, 2016 13:30
-
-
Save gtempesta/f3a478b6350ca6012dff9e333426fc74 to your computer and use it in GitHub Desktop.
Easiest way to draw a Circle in swift 3.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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