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

前端 未结 2 944
谎友^
谎友^ 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:13

    As I'm concerned, may be the CAShapeLayer is better way to achieve the pie chart. By doing that, you can use

    [layer hitTest:] 
    

    method to deal with the touch action.

提交回复
热议问题