iOS:按钮的非方形命中区域
我需要制作一些彼此重叠的三角形按钮。
虽然UIButtons可以将透明图像作为背景,而UIControl可以具有自定义视图,但这些视图的命中区域始终是方形的。 如何为我的按钮创建一个三角形的hitarea?
我来自FLASH背景,所以我通常会为我的视图创建一个hitarea,但我不相信我能在Cocoa中做到这一点。
有小费吗?
您可以通过UIButton
并提供自己的:
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { // return YES if point is inside the receiver's bounds; otherwise, NO. }
Apple的UIView文档提供了详细信息,例如确认该point
已经在接收器的坐标系中。