Thursday, March 22, 2012

UINavigationBar tintColor, why not backgroundColor or color?

I don't know whether its just me but, whenever I'm thinking of changing the colour of an UI element first thing I would do is look for methods like setBackgroundColor or setColor before I think of subclassing the element and overriding its drawRect (for more customised application of colours you will have to override "drawRect"). Unfortunately in objective c UINavigationBar colour is reffered as tintColor. So I thought of documenting it for future reference.

It doesn't have any methods like "setBackgroundColor" or "setColor". If you think about it we really don't change the background colour of the UINavigationBar. The reason for me to think this way was because when we set a colour using setTintColor it applies the colour not only to the UINavigationBar but also to its elements (keeping the text/images unharmed of course). So I think "setTintColor" looks as if it applies a tint over the UINavigationBar. May be this is why they chose "setTintColor" over "setBackgroundColor" and "setColor".

Please feel free to comment.

1 comment:

Anonymous said...

When you specify a tint for a view, the tint is automatically propagated to all subviews in the view’s hierarchy.