Skip to content

Instantly share code, notes, and snippets.

@vasarhelyia
Last active December 14, 2019 02:26
Show Gist options
  • Save vasarhelyia/4eef15ccb5507f301dedb0732071aa59 to your computer and use it in GitHub Desktop.
Save vasarhelyia/4eef15ccb5507f301dedb0732071aa59 to your computer and use it in GitHub Desktop.
This produces a circle, not a square
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let rectShape = CAShapeLayer()
let bounds = CGRect(x: 400.0,
y: 400.0,
width: -200.0,
height: -200.0)
let rectPath = UIBezierPath(roundedRect: bounds,
byRoundingCorners: .allCorners,
cornerRadii: .zero)
rectShape.path = rectPath.cgPath
rectShape.strokeColor = UIColor.black.cgColor
rectShape.fillColor = UIColor.clear.cgColor
rectShape.lineWidth = 3
self.view.layer.addSublayer(rectShape)
}
}
@vasarhelyia
Copy link
Author

Produces:

Screen Shot 2019-12-13 at 6 25 54 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment