0

I have to create a very simple GUI for an iPad application.

I have a 1024x768 png and I want to use this file for the GUI. I have to make an area of this png tappable and able to run some action. This area is not a rectangle (it's a trapezoid) so I can't create a button. Is it possible somehow?

matt
  • 485,702
  • 82
  • 818
  • 1,064
Luka
  • 1,491
  • 4
  • 19
  • 36

2 Answers2

2

you can do it in code by overriding - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event and - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event in the view that's displaying the image. that'll mean you have to decide whether a point is within the touch area of the image.

Mike K
  • 2,235
  • 1
  • 11
  • 6
0

Make a UIImageView that displays an image which shows the trapezoid and is otherwise transparent.

Turn on the UIImageView's userInteractionEnabled to make it tappable.

Put a UITapGestureRecognizer on the UIImageView to respond to the tap.

In the tap gesture recognizer's action handler, respond only if the point where the user tapped is non-transparent. To learn whether the point the user touched is transparent, see Retrieving a pixel alpha value for a UIImage.

Community
  • 1
  • 1
matt
  • 485,702
  • 82
  • 818
  • 1,064