Skip to content

Instantly share code, notes, and snippets.

@simonwuyts
Created June 5, 2017 13:03
Show Gist options
  • Save simonwuyts/0af155b38839dc43f5533e67a6d74be0 to your computer and use it in GitHub Desktop.
Save simonwuyts/0af155b38839dc43f5533e67a6d74be0 to your computer and use it in GitHub Desktop.
Shape
// Define Bubble Shape
let bubblePath = UIBezierPath()
// Top left corner
bubblePath.move(to: topLeft(0, borderRadius))
bubblePath.addCurve(to: topLeft(borderRadius, 0), controlPoint1: topLeft(0, borderRadius / 2), controlPoint2: topLeft(borderRadius / 2, 0))
// Top right corner
bubblePath.addLine(to: topRight(borderRadius, 0))
bubblePath.addCurve(to: topRight(0, borderRadius), controlPoint1: topRight(borderRadius / 2, 0), controlPoint2: topRight(0, borderRadius / 2))
// Bottom right corner
bubblePath.addLine(to: bottomRight(0, borderRadius))
bubblePath.addCurve(to: bottomRight(borderRadius, 0), controlPoint1: bottomRight(0, borderRadius / 2), controlPoint2: bottomRight(borderRadius / 2, 0))
// Bottom left corner
bubblePath.addLine(to: bottomLeft(borderRadius, 0))
bubblePath.addCurve(to: bottomLeft(0, borderRadius), controlPoint1: bottomLeft(borderRadius / 2, 0), controlPoint2: bottomLeft(0, borderRadius / 2))
bubblePath.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment