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。

文章详细解释了在iOS5及之后版本中,UINavigationBar、UIToolbar和UITabBar的drawRect:方法的调用规则变化,并提供了在iOS5和之后版本中如何正确实现这些UI组件的方法。
1394

被折叠的 条评论
为什么被折叠?



