This is an example code for a stackoverflow question
While a storyboard file looks like
the app will show the buttons as
The shape of the button is set by proving a path which will mask the button.
var shape: UIBezierPath = UIBezierPath() {
didSet{
let l = CAShapeLayer()
l.path = shape.cgPath
self.layer.mask = l
}
}
The hit testing is done by determining if an event was triggered at a point that lays in the given shape path, there-for a touch will only be recognize at the visible parts of the button.
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return shape.cgPath.contains(point)
}
A more complex form using four triangles and a circle, all buttons: