Creating an irregular UIButton in Swift, where the transparent parts cannot be displayed

I am making a pie chart where each sector is a separate button with a background image, but UIButton has a rectangular shape and all buttons overlap. Is there a way to make UIButton an exact form of the wrong image (in Swift) so that this does not happen?

Any help would be appreciated

+2
source share
2 answers

You can use UIBezierPath or CGPath to define sections of the pie chart and use containsPoint: or CGPathContainsPoint to detect touch

+2
source

, CAShapeLayer . ,

[layer hitTest:] 

.

+1

All Articles