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 636851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:33:35+00:00 2026-05-13T20:33:35+00:00

I have a favorite image to display on a UIBarButtonItem , on an toolbar.

  • 0

I have a favorite image to display on a UIBarButtonItem, on an toolbar.

How do you do to change it when this item is unselected/selected? like this screenshot:

enter image description here

Thanks!

  • 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-05-13T20:33:35+00:00Added an answer on May 13, 2026 at 8:33 pm

    You can make two arrays with UIBarButtonItems: one with the first image and one with the second image. Like this:

    // array with unselected
    UIBarButtonItem *unselectedItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_unselected.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(doStuff:)];
    self.itemsWithUnselected = [NSArray arrayWithObject:unselectedItem]; // declared as NSArray*
    [unselectedItem release];
    
    // array with selected
    UIBarButtonItem *selectedItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_selected.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(doStuff:)];
    self.itemsWithSelected = [NSArray arrayWithObject:selectedItem]; // declared as NSArray*
    [selectedItem release];
    

    and then switch between the two sets of toolbar items with:

    toolbar.items = self.itemsWithSelected; // or self.itemsWithUnselected
    

    If you have more than just the one button on your toolbar then just add the rest of the items to both arrays.

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

Sidebar

Related Questions

I have two table like this table_CN (_id, name, phone, favorite, title) table_EN (_id,
I have a favorite table containing some fields like login_id,driver_id(One login_id may have many
I have a favourites button and I want it to change it's image depending
Ok so I have this <img width=38 height=39 onclick=jreviews.favorite.add(this,{listing_id:2655}) class=imgFavoriteAdd alt=Add to favorites id=jr_favoriteImg2655
i have a favorite icon defined for my web-site: <link rel=shortcut icon type=image/x-icon href=favicon.ico>
I would like to have something similar on my site like the follow/favorite question
Does anyone have a favorite style site that posts the latest and greatest sites
I have a option called favorite, each time I choose my favorite song, the
I have 3 tables called radio, song, and artist controlled by favorite. Now I
I have this code, it works for a rotating menu that is obviously a

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.