Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:00:00+00:00 2026-06-09T10:00:00+00:00

I have two images for a button, one for normal, and one for selected.

  • 0

I have two images for a button, one for normal, and one for selected. And i want it to act the same way a rounded rect button acts as when you touch down, the buttons image changes, and if you drag outside, the image changes back to normal. Heres what i tried.

First, I made a custom view controller, and then i added methods in the implementation to it which is what you see down here. And i hooked these methods up to my 2 buttons, my play ‘button’ and my ‘settings’ button.

- (IBAction)playButtonSelected:(UIButton *)sender {  //this is for event touchDown
       [sender setImage:[UIImage imageNamed:@"PlayButtonSelected.png"] forState:UIControlStateNormal];

}


- (IBAction)playButtonNotSelected:(id)sender { //this is for event touchUpOutside
    [sender setImage:[UIImage imageNamed:@"PlayButton.png"] forState:UIControlStateNormal];

}



- (IBAction)settingsButtonSelected:(UIButton *)sender { //this is for event TouchDown
        [sender setImage:[UIImage imageNamed:@"SettingsButtonSelected.png"] forState:UIControlStateNormal];
}

- (IBAction)settingsButtonNotSelected:(id)sender { //this is for event touchUpOutside
      [sender setImage:[UIImage imageNamed:@"SettingsButtons.png"] forState:UIControlStateNormal];
}

Well, I did this, and it worked pretty good, but there are 2 problems.

1st: If I have like 20 buttons I would have to have 40 methods. This isn’t really a problem, I just think its something to think about as a potential issue.

2nd: When I drag my button outside, I would like for it to switch to the normal image before the user actually releases his finger. As of right now the image only defaults when the finger is released, and not when the finger is moved at a certain distance so that the touchUpInside command will not run. I want this because its basically the standard. And it would also help the user to understand that he can take back his impulsive behavior of clicking buttons if he so desires.

Cool, any help would be a lot of help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:00:01+00:00Added an answer on June 9, 2026 at 10:00 am

    You only need to set the selected and normal images once (when you create the button for instance)

    the “state” argument lets you set different images for different states. You only need to write this code once :

    [playerButton setImage:[UIImage imageNamed:@"PlayButton.png"] forState:UIControlStateNormal];
    [playerButton setImage:[UIImage imageNamed:@"PlayButtonSelected.png"] forState:UIControlStateSelected];
    

    Edit: you can also do this from Interface Builder from the attributes inspector

    Normal State
    Selected State

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to change the look of the button with two images, one Normal
I have two images. One that is normal, and another that is more colourised.
I have a two sprite images. One image contains the body of a rounded
I have two images, both taken at the same time from the same detector.
I have two images - 1)a rectangular one, displaying the actual content and 2)a
I have two images (JPGs). Both are the same width but image2 is shorter
I have two images in the background of my html doc. One positioned top
I have a UIButton which has images set for both Normal and Selected State.
I have two activities: one displays an image and a button, the other displays
I have made one screen with two images and I would like to add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.