Created
April 8, 2015 13:18
-
-
Save sergeytimoshin/b4f44f74941d41fea586 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let path = UIBezierPath() | |
let radius : CGFloat = 4 | |
let topRightStartAngle = -CGFloat(M_PI_2) | |
let topRightEndAngle : CGFloat = 0.0 | |
let bottomRightStartAngle : CGFloat = 0.0 | |
let bottomRightEndAngle : CGFloat = -(CGFloat(M_PI) * 3) / 2 | |
let bottomRightCenterPoint = CGPoint(x: CGRectGetWidth(self.bounds) - radius, y: CGRectGetHeight(self.bounds) - radius) | |
let bottomLeftStartAngle : CGFloat = -((CGFloat(M_PI)*3)/2) | |
let bottomLeftEndAngle : CGFloat = -CGFloat(M_PI) | |
let topLeftStartAngle: CGFloat = -CGFloat(M_PI) | |
let topLeftEndAngle : CGFloat = -(CGFloat(M_PI)/2) | |
path.moveToPoint(CGPoint(x: radius, y: 0)) | |
path.addLineToPoint(CGPoint(x: CGRectGetWidth(self.bounds) - radius, y: 0)) | |
path.addArcWithCenter(CGPoint(x: CGRectGetWidth(self.bounds) - radius, y: radius), radius: radius, startAngle: topRightEndAngle, endAngle: topRightEndAngle, clockwise: true) | |
path.addLineToPoint(CGPoint(x: CGRectGetWidth(self.bounds), y: CGRectGetHeight(self.bounds) - radius)) | |
path.addArcWithCenter(bottomRightCenterPoint, radius: radius, startAngle: bottomRightStartAngle, endAngle: bottomRightEndAngle, clockwise: true) | |
path.addLineToPoint(CGPoint(x: radius, y: CGRectGetHeight(self.bounds))) | |
path.addArcWithCenter(CGPoint(x: radius, y: CGRectGetHeight(self.bounds) - radius), radius: radius, startAngle: bottomLeftStartAngle, endAngle: bottomLeftEndAngle, clockwise: true) | |
path.addLineToPoint(CGPoint(x: 0, y: radius)) | |
path.addArcWithCenter(CGPoint(x: radius, y: radius), radius: radius, startAngle: topLeftStartAngle, endAngle: topLeftEndAngle, clockwise: true) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment