Created
December 13, 2016 13:52
-
-
Save geek1706/987810f72b3f4ef9a5af9071f723b700 to your computer and use it in GitHub Desktop.
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
override func draw(_ rect: CGRect) { | |
UIColor.white.setFill() | |
let minX: CGFloat = 0 | |
let maxX = rect.width | |
let maxY = rect.height | |
let midX = rect.midX | |
let circleRadius: CGFloat = 45 | |
let roundingRadius: CGFloat = 6 | |
let path = UIBezierPath() | |
path.move(to: CGPoint(x: minX, y: circleRadius)) | |
path.addArc(withCenter: CGPoint(x: midX - circleRadius - roundingRadius, y: circleRadius - roundingRadius), radius: roundingRadius, startAngle: CGFloat.pi/2, endAngle: 0, clockwise: false) | |
path.addArc(withCenter: CGPoint(x: midX, y: circleRadius), radius: circleRadius, startAngle: CGFloat.pi + tan(roundingRadius/circleRadius), endAngle: CGFloat.pi * 2 - tan(roundingRadius/circleRadius), clockwise: true) | |
path.addArc(withCenter: CGPoint(x: midX + circleRadius + roundingRadius, y: circleRadius - roundingRadius), radius: roundingRadius, startAngle: CGFloat.pi, endAngle: CGFloat.pi/2, clockwise:false) | |
path.addLine(to: CGPoint(x: maxX, y: circleRadius)) | |
path.addLine(to: CGPoint(x: maxX, y: maxY)) | |
path.addLine(to: CGPoint(x: minX, y: maxY)) | |
path.close() | |
path.fill() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment