Creating an irregular UIButton in Swift where transparent parts are not tappable

前端 未结 2 942
谎友^
谎友^ 2021-01-07 04:17

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 the buttons overlap. Is there a way to m

2条回答
  •  爱一瞬间的悲伤
    2021-01-07 05:02

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

提交回复
热议问题