I am trying to set the tint color for a UIBarButtonItem using the following code, but all I get is a black button. Is there a way to accomplish this without the need to use custom images?
[[UIBarButtonItem appearance] SetTintColor:[UIColor clearColor]]:
create a custom UIBarButtonItem with a button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];
//set the frame of the button to the size of the image (see note below)
button.frame = CGRectMake(0, 0, 24, 24);
button.backgroundColor=[UIColor clearColor];
//create a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
If your UIToobar or UINavigationBar is translucent, bar buttons automatically become translucent.
[[self.navigationController navigationBar] setTranslucent:YES];
AFAIK, You can't make a bar button alone translucent.
来源:https://stackoverflow.com/questions/9138490/make-a-cleartransluscent-uibarbutttonitem-ios-5