Skip to content

Instantly share code, notes, and snippets.

@trilliwon
Created February 26, 2019 08:01
Show Gist options
  • Save trilliwon/438c67a4429a87aadbdacb6287448ffa to your computer and use it in GitHub Desktop.
Save trilliwon/438c67a4429a87aadbdacb6287448ffa to your computer and use it in GitHub Desktop.
class TriangleView: UIView {
override func draw(_ rect: CGRect) {
guard let context = UIGraphicsGetCurrentContext() else { return }
context.beginPath()
context.move(to: CGPoint(x: rect.midX, y: rect.minY))
context.addLine(to: CGPoint(x: rect.minX, y: rect.maxY))
context.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
context.closePath()
context.setFillColor(UIColor.black.withAlphaComponent(0.6).cgColor)
context.fillPath()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment