I want to do a shift key. When I click it, the key will change to other letters. How can I make it bright when clicking this shift button like in iphone ? Can you give some example codes ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’d like a button’s image to change when tapped, and then back, you can use the -[setImage:forState:] method. For this example, imagine yourself having 2 images: image_one.png and image_two.png for the unpressed and pressed images respectively.
Suppose you have a button like so:
You can add a target and action that will change the image back and forth. To see which image it is currently, I’d use the tag property.
And have something like the following in the setImage method:
When you first tap the button, it selects. Tapping it another time will unselect it – just like the keyboard’s shift button.