UIBarStyleBlack vs tintColor black

2019-04-27 12:38发布

问题:

What is the difference between setting the tintColor property of UINavigationBar to [UIColor blackColor] and setting barStyle to UIBarStyleBlack on opaque navigation bar?

回答1:

There are a few subtle differences. For example, on iPad, you get a matte style with the tint color, but a glossy one with the barStyle.

Also, the color of bordered UIBarButtonItems is slightly different; with the black barStyle, they are gray, which makes it easier to distinguish the darker highlighted state, while with a black tint color, the buttons look almost identical in normal and highlighted state.

I think UIBarButtonItems with 'Done' style also look different, but I'm not sure about that.



回答2:

There are only 2 options for barStyle: default and black. However, you can set the tintColor to anything you like: red, blue, green, orange, some funny rgb defined color, etc. The default tintColor for UIBarStyleBlack is, not surprisingly, [UIColor blackColor].

I recommend you just play around with how they look. Set the tint to something fun and toggle between styles. See what you prefer for your app.