Right now I am working on a menu for a game. Instead of buttons (UIButton) I would like to use images made in photoshop as clickable menu items. UIButton does not allow me the movement to design menu items as I want to (PS. I am a beginner so I don't know many details).
So my question is: how can I make an image clickable so that it behaves in the same way as a button?
Thanks a lot!
Last edited by BrightMedia; 12-10-2011 at 11:36 AM.
Right now I am working on a menu for a game. Instead of buttons (UIButton) I would like to use images made in photoshop as clickable menu items. UIButton does not allow me the movement to design menu items as I want to (PS. I am a beginner so I don't know many details).
So my question is: how can I make an image clickable so that it behaves in the same way as a button?
Thanks a lot!
- Patrick
The easiest thing to do this is to create a UITapGestureRecognizer and install it into the object. That works for any UIView object.
Use the UIGestureRecognizer method initWithTarget:action: to initialize the gesture recognizer, and the UIView method addGestureRecognizer to add the recognizer to the view.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
The easiest thing to do this is to create a UITapGestureRecognizer and install it into the object. That works for any UIView object.
Use the UIGestureRecognizer method initWithTarget:action: to initialize the gesture recognizer, and the UIView method addGestureRecognizer to add the recognizer to the view.
No, I mean explain why you think you can't use a UIButton.
I see. Well, I am using translucent background in these images. What I found out is that the button will ignore translucent backgrounds and make them white instead, and also give the image (that i am using as background in this button) a rectangular shape.
The easiest thing to do this is to create a UITapGestureRecognizer and install it into the object. That works for any UIView object.
Use the UIGestureRecognizer method initWithTarget:action: to initialize the gesture recognizer, and the UIView method addGestureRecognizer to add the recognizer to the view.
Thanks again for your solution! I read more about this but I'm having the following question:
How do I connect the image with the method UITapGestureRecognizer?
I see. Well, I am using translucent background in these images. What I found out is that the button will ignore translucent backgrounds and make them white instead, and also give the image (that i am using as background in this button) a rectangular shape.
I see. Well, I am using translucent background in these images. What I found out is that the button will ignore translucent backgrounds and make them white instead, and also give the image (that i am using as background in this button) a rectangular shape.
It wont. You can set your image as the button's image and it will be fine. Just set the type to Custom.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.