Skip to content

Instantly share code, notes, and snippets.

@Jesse-calkin
Last active March 15, 2016 20:43
Show Gist options
  • Save Jesse-calkin/32d55564f2e4d823bf6d to your computer and use it in GitHub Desktop.
Save Jesse-calkin/32d55564f2e4d823bf6d to your computer and use it in GitHub Desktop.
import UIKit
import XCPlayground
let page = XCPlaygroundPage.currentPage
let view = UIView(frame: CGRect(x: 0, y: 0, width: 750, height: 750))
page.liveView = view
let position = CGPoint(x: 0, y: 0)
let size = CGSize(width: 740, height: 740)
let lineWidth: CGFloat = 50
let arcSize = CGSize(width: size.width - lineWidth, height: size.height - lineWidth)
let arc1 = CAShapeLayer()
arc1.lineWidth = lineWidth / 4
arc1.path = UIBezierPath(ovalInRect: CGRect(origin: position, size: arcSize)).CGPath
arc1.bounds = CGRect(origin: position, size: arcSize)
arc1.strokeColor = UIColor.grayColor().CGColor
arc1.fillColor = UIColor.clearColor().CGColor
arc1.position = view.center
view.layer.addSublayer(arc1)
let arc2 = CAShapeLayer()
arc2.lineWidth = lineWidth
arc2.path = UIBezierPath(ovalInRect: CGRect(origin: position, size: arcSize)).CGPath
arc2.bounds = CGRect(origin: position, size: arcSize)
arc2.strokeStart = 0.0
arc2.strokeEnd = 0.53
arc2.strokeColor = UIColor.greenColor().CGColor
arc2.fillColor = UIColor.clearColor().CGColor
arc2.position = view.center
view.layer.addSublayer(arc2)
let transform = CATransform3DRotate(arc2.transform, -90.0 * CGFloat(M_PI) / 180.0, 0.0, 0.0, 1.0)
arc2.transform = transform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment