Last active
December 14, 2019 02:26
-
-
Save vasarhelyia/4eef15ccb5507f301dedb0732071aa59 to your computer and use it in GitHub Desktop.
This produces a circle, not a square
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 | |
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Produces: