I am using following code to create a UIBarButtonItem:
UIBarButtonItem* searchBarButton = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"search_picto"] style:UIBarButtonItemStyleBordered target:self action:@selector(actionSearch:)] autorelease];
searchBarButton.tintColor = [UIColor colorWithRed:0.27 green:0.60 blue:0.20 alpha:1.00];
I add this and another button to a UIToolbar, not sure if that’s relevant.
This works fine and gives me the look I intended:

The problem is that with iOS 4 (which I have to support) I can’t set the tintColor. Unrecognized Selector. How can I create such a button for iOS 4? I need to be able to set the tintColor and have UIBarButtonItemStyleBordered.
Thanks for your help.
I got it to work like this:
UISegmentedControl* searchButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"", nil]];
[searchButton setImage:[UIImage imageNamed:@"search_picto"] forSegmentAtIndex:0];
searchButton.momentary = YES;
searchButton.segmentedControlStyle = UISegmentedControlStyleBar;
searchButton.tintColor = [DELEGATE.config getColor:IFXShopConfigScopeShop name:@"navigationTint"];
[searchButton addTarget:self action:@selector(actionSearch:) forControlEvents:UIControlEventValueChanged];
You have to initialize it with one empty NSString, otherwise you can’t set an image. Also the addTarget has to use UIControlEventValueChanged
tintColorwas added in iOS5, for iOS4 here you have a solution