简体   繁体   中英

in iPhone SDK How to change the color of BarButton Item

How to change color of leftBarButtonItem of UIBarButtonItem in NavigationBar?

if I am trying to set image in bar button through interfaceBuilder it shows border on image in bar button so is there any specific size for image for bar button or how to set image with-out showing border in it ?

If I am adding BarButton dynamically it doesn"t appear while running App and if I am adding leftbarButton in xib only and connecting outlets then the leftbar button become visible but I am not able to assign customview view to it my ultimate goal is to change the color of left bar buttton

Please Help and Suggest, Thanks

Create the bar buttom item with a custom view using -[UIBarButtonItem initWithCustomView:] . That way, you have all the control you want over the appearance.

I think you can use:

- (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action

You can set custom image for your bar button.

If it's just the colour you want to change, add the button to the bar and then set the tint colour of the bar (see docs on UINavigationBar or UIToolBar). This of course changes the bar colour as well as the button however, but it's good practice (UI consistency wise) to use the same colour for UIBarButtonItems and their bars especially if you're using out-of-the-box buttons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM