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

  • SEARCH
  • Home
  • 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 7788791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:05:36+00:00 2026-06-01T21:05:36+00:00

I need 2 different images for highlighted state for an UIButton . I’ve these

  • 0

I need 2 different images for highlighted state for an UIButton.

I’ve these lines of code:

- (IBAction)buttonPressed:(id)sender
{
    UIImage *followImageHighlighted = [UIImage imageNamed:@"follow-hilite.png"];
    UIImage *unfollowImageHighlighted = [UIImage imageNamed:@"unfollow-hilite.png"];
    if ([sender isSelected]) {
        // set this image for the next time the button will pressed
        [sender setImage:unfollowImageHighlighted forState:UIControlStateHighlighted];
    } else {
        // set this image for the next time the button will pressed
        [sender setImage:followImageHighlighted forState:UIControlStateHighlighted];
    }
}

- (void)viewDidLoad
{
    // ...
    UIImage *followImage = [UIImage imageNamed:@"follow.png"];
    UIImage *unfollowImage = [UIImage imageNamed:@"unfollow.png"];
    [self.followButton setImage:followImage forState:UIControlStateNormal];
    [self.followButton setImage:unfollowImage forState:UIControlStateSelected];
}

The problem is that every time I press the button I see the highlighted image follow-hilite.png.

Can’t I change the highlighted image for a button on the road?

I think this is a bad limitation because when the button is selected (thus, “Following”) and an user press it, he see the default image, then when it touch up the image is that for selected state and when the network operation is completed then the button image switch correctly to the selected one.

Ideas?

EDIT

- (IBAction)followButtonTapped:(id)sender
{
    BOOL isFollowed = [sender isSelected];
    NSString *urlString = isFollowed ? kUnfollowURL : kFollowURL;
    // operation [...]
    [self.followButton setSelected:(isFollowed) ? NO : YES];
    self.user.followed = !isFollowed;
}

I explain better the problem:

  • button in default state: black text on white background
  • button in selected state: white text on black background

If the target user is not followed, the button is in default state and if I try to press it I see the correct highlighted image.

BUT if the target user is followed and the button is in selected state, if I try to press it (and hold the finger) I see the button with black text on white background. This is very ugly and this is my problem.

  • 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-01T21:05:39+00:00Added an answer on June 1, 2026 at 9:05 pm

    I’ve solved with:

    [myButton setImage:imageSelectedHover forState:(UIControlStateSelected | UIControlStateHighlighted)];

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

Sidebar

Related Questions

I need to load about 60 images, each on a different page, in to
I need to concatenate different lines in a string. To do so, I need
I have A MapView with Multiple annotations. But I need to put different images
I'm working on expandable listview. I need to display different images in imageview of
usual but I need to have different custom radio button images per button. So
I need to do series of animation on 4 different images. The images are
I need to let user navigate back and forward through different images (from 10
I need the user to select from 10 different images and I will like
I have recently had several situations where I need different data from the same
I'm coding an android app for parsing sms messages. I need different rules for

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.