iOS: Non-square hit areas for buttons

前端 未结 1 733
暖寄归人
暖寄归人 2021-01-06 18:09

I need to make some triangular buttons that overlap each other.

While UIButtons can take transparent images as backgrounds, and UIControls can have custom views, the

相关标签:
1条回答
  • 2021-01-06 18:20

    You can achieve this by subclassing UIButton and providing your own:

    - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
        // return YES if point is inside the receiver’s bounds; otherwise, NO.
    }
    

    Apple's UIView Documentation provides the details, such as confirming that point is already in the receiver's coordinate system.

    0 讨论(0)
提交回复
热议问题