在子类化UIView时,会自动调用drawRect方法,可以在子类中重载该函数,以实现自己的功能。
另外,当需要重绘时,可调用setNeedsDisplay 或者 setNeedsDisplayInRect方法,而不能直接调用drawRect方法。
This method is called when a view is first
displayed or when an event occurs that invalidates a visible part of the view. You should never call this method directly yourself. To invalidate part of your view, and thus cause that portion to be redrawn, call the setNeedsDisplay or setNeedsDisplayInRect:
method instead.
本文深入探讨了在子类化UIView时如何利用drawRect方法实现自定义功能,以及如何通过setNeedsDisplay和setNeedsDisplayInRect方法有效触发视图重绘,避免直接调用drawRect导致的性能问题。
3150

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



