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
  • 515,959
  • 87
  • 875
  • 1,141
lucaconlaq
  • 1,511
  • 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,227
  • 1
  • 12
  • 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
  • 515,959
  • 87
  • 875
  • 1,141