Created
September 8, 2019 06:48
-
-
Save badrinathvm/6917fa477dcef5ee24daf38bccb084a0 to your computer and use it in GitHub Desktop.
Add a custom path
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
func customPath() -> UIBezierPath { | |
let path = UIBezierPath() | |
path.move(to: CGPoint(x: 0, y: 200)) | |
let endPoint = CGPoint(x: 500, y: 200) | |
let randomYShift = 200 + drand48() * 300 | |
let cp1 = CGPoint(x: 100, y: 100 - randomYShift) | |
let cp2 = CGPoint(x: 200, y: 100 + randomYShift + 400) | |
path.addCurve(to: endPoint, controlPoint1: cp1, controlPoint2: cp2) | |
return path | |
} | |
class CurvedView: UIView { | |
override func draw(_ rect: CGRect) { | |
//do some fancy curve drawing | |
let path = customPath() | |
path.lineWidth = 3 | |
path.stroke() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment