Quote:
Originally Posted by fireball916
I'm new to coding in general and I'm just trying to make an app for my dad. It's not a fancy app or anything. Is it possible to bush a button and it turn into a image? And then push it again to convert back into a button? I've Googled it and can't seem to find a answer. Thanks!
(P.S. I know it's a noob question but I'm new to this and trying to learn how to make apps and stuff. Thanks!)
|
There are a couple of options.
A simple way to do this would be to put a normal rounded rectangle button and a custom button at the same location in your nib file. You can select an image for the custom button and it essentially becomes a clickable image. It looks like an image but has all the same features and behavior as a button.
Hook up outlets to both buttons . Make the normal button visible and set the hidden property on the "image button" to true at first, so only the normal button is visible.
Create a "switchButtons" IBAction (a method that gets called when a control like a button is triggere) and link both buttons to it.
In the action method, switch the hidden state of both buttons.
Code:
normalButton.hidden = !normalButton.hidden;
imageButton.hidden = !imageButton.hidden;
You can make the IBAction method do other things to if you want, but that's the basic idea.