-1

The UINavigationBar is RedColour.

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"Hello" style:UIBarButtonItemStylePlain target:self action:@selector(bbPressed:)];

self.navigationItem.rightBarButtonItem=barButton ;

Now i need to give a black background colour for the above BarButton. How can i do this programatically ?

I have tried this using the IB and it works, but i need to do it using code only.

Steps how to do it in IB;

change background colour to RED. Change the style to - BlackTranslucent

I tried setting these using the code but it doesn't work.

Help

shajem
  • 2,111
  • 5
  • 22
  • 30

1 Answers1

0

You can't change default styles of UIBarButton. Use [[UIBarButtonItem alloc] initWithCustomView:yourView] where yourView is customized UIButton.

Kyr Dunenkoff
  • 8,090
  • 3
  • 23
  • 21