In iOS 5, the UINavigationBar, UIToolbar, and UITabBar implementations have changed so that the drawRect: method is not called unless it is implemented in a subclass. Apps that have re-implemented drawRect: in a category on any of these classes will find that
the drawRect: method isn't called. UIKit does link-checking to keep the method from being called in apps linked before iOS 5 but does not support this design on iOS 5 or later. Apps can either:
Use the customization API for bars in iOS 5 and later, which is the preferred way.
//原文地址 http://blog.youkuaiyun.com/diyagoanyhacker/article/details/6876543
Subclass UINavigationBar (or the other bar classes) and override drawRect: in the subclass.
通过官方的说法我们可以看出:- drawRect:只有定义在它们的子类中才会被执行.并且ios5 也定义了设置背景的API。