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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:45:57+00:00 2026-06-04T17:45:57+00:00

I need to use a simple UIBarButtonItem in a UIToolBar. I used this code

  • 0

I need to use a simple UIBarButtonItem in a UIToolBar.

I used this code to add the button with my custom image to the navigation bar:

UIBarButtonItem *cloneButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"image_sheep.png"] style:UIBarButtonItemStylePlain target:self action:@selector(clone)];
NSArray *rightItems = [NSArray arrayWithObject:cloneButton];
self.navigationItem.rightBarButtonItems = rightItems;

The result is what I want and it looks like this

navigation bar http://img207.imageshack.us/img207/3383/navigationbara.jpg

When doing the same thing in a UIToolBar that I’m adding to a UITableViewCell’s contentView

UIBarButtonItem *cloneButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"image_sheep.png"] style:UIBarButtonItemStylePlain target:self action:@selector(clone)];
UIBarButtonItem *leftSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
toolbar.items = [NSArray arrayWithObjects:leftSpace, cloneButton, nil];

The problem is that I get something like this:

toolbar http://img209.imageshack.us/img209/1374/toolbary.jpg

This is surely due to the fact that UINavigationBar and UIToolBar are not drawn the same way…
Can someone please point out how to resolve this 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-04T17:45:58+00:00Added an answer on June 4, 2026 at 5:45 pm

    That’s how UIToolbar is supposed to work. Per the documentation:

    Toolbar images that represent normal and highlighted states of an item derive from the image you set using the inherited image property from the UIBarItem class. For example, the image is converted to white and then bevelled by adding a shadow for the normal state.

    That said, you might be able to get the result you want by creating a UIBarButtonItem with a custom view instead of an image. Like so:

    UIImage *sheepImage = [UIImage imageNamed:@"image_sheep.png"];
    UIButton *sheepButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [sheepButton setImage:sheepImage forState:UIControlStateNormal];
    [sheepButton addTarget:self action:@selector(clone) forControlEvents:UIControlEventTouchUpInside];
    [sheepButton setShowsTouchWhenHighlighted:YES];
    [sheepButton sizeToFit];
    UIBarButtonItem *cloneButton = [[UIBarButtonItem alloc] initWithCustomView:sheepButton];
    

    I haven’t tested this, so I don’t know if it will work.

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

Sidebar

Related Questions

I have developed a simple library in Ruby and need to use this in
I need to use or stimulate a very simple session object inside my WCF
I need to retrieve a simple page and use the data that it returns.
So, I need use this event so I can navigate trought blog posts. I
I have a simple 3 column csv file that i need to use python
I'm looking for a super simple jQuery extension. Basically I need to use some
Need to use own imaged markers instead built-in pins. I have several questions. 1.
i need to use the animate property for a less than usual activity. i
I need to use scp update some directory at another server. It is similar
I need to use some classes inside the app_code folder of a website project

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.