views:

33

answers:

1

I created a toolbar with a translucent black style like so:

UIToolbar *toolbar = [UIToolbar new];
toolbar.barStyle = UIBarStyleBlack;
toolbar.translucent = YES;

I created a button item for it:

UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithImage:nil
                            style:UIBarButtonItemStyleBordered
                          target:self
                            action:@selector(mySelector:)];

I noticed that the button when in normal state appears light grey and turns to full black only when I press on it. This seems to be the opposite of how it should function (e.g. Photo app). I'd like it do be black in normal state and lighter when pressed. What am I missing?

+1  A: 

Change the barstyle to UIBarStyleBlackTranslucent, as dumb as it sounds, and I believe it returns it to normal.

Kolin Krewinkel
You're right! I guess that means the note in documentation should be ignored: "UIBarStyleBlackTranslucent Deprecated. Use UIBarStyleBlack and set the translucent property to YES instead."
Anna
Some part of me also thinks that if you put setTranslucent before the barStyle it might affect how it's displayed - just a hunch. It's not always best to ignore warnings, however in this case it's unlikely to be changed.
Kolin Krewinkel
I had the same instinct about switching the order of properties but alas. I'll stick with the "depreciated" method for now.
Anna