Created
June 16, 2020 13:18
-
-
Save alexnikol/fd0bd1c182022b68a124a9c65e6fa212 to your computer and use it in GitHub Desktop.
UIBezierPath-ReadyToUseShapes
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
//Paths Part | |
let rect = UIBezierPath(rect: CGRect(x: 50, y: 50, width: 50, height: 50)) | |
let oval = UIBezierPath(ovalIn: CGRect(x: 120, y: 120, width: 100, height: 50)) | |
let roundedRect = UIBezierPath(roundedRect: CGRect(x: 200, y: 200, width: 50, height: 50), | |
cornerRadius: 10.0) | |
//Shapes | |
let rectShape = CAShapeLayer() | |
rectShape.path = rect.cgPath | |
rectShape.lineWidth = 4.0 | |
rectShape.fillColor = UIColor.clear.cgColor | |
rectShape.strokeColor = UIColor.orange.cgColor | |
view.layer.addSublayer(rectShape) | |
let ovalShape = CAShapeLayer() | |
ovalShape.path = oval.cgPath | |
ovalShape.lineWidth = 4.0 | |
ovalShape.fillColor = UIColor.clear.cgColor | |
ovalShape.strokeColor = UIColor.orange.cgColor | |
view.layer.addSublayer(ovalShape) | |
let roundedRectShape = CAShapeLayer() | |
roundedRectShape.path = roundedRect.cgPath | |
roundedRectShape.lineWidth = 4.0 | |
roundedRectShape.fillColor = UIColor.clear.cgColor | |
roundedRectShape.strokeColor = UIColor.orange.cgColor | |
view.layer.addSublayer(roundedRectShape) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment