When is -[UIView drawRect:] Method Invoked?

谁说胖子不能爱 提交于 2019-12-08 19:16:43

问题


Is it invoked just before the main view is going to be shown

Can we call it whenever we want?


回答1:


It's called whenever the view or part of the view needs to be drawn or redrawn.

It's called when you first display the view. It's called when you alter the view. In the life cycle of a view, it may be called hundreds or even thousands of times. For example, in a text view, it is called every time a new text character is entered.

Any change in the program state that the view must reflect visually should trigger a redraw by calling setNeedsDisplay. This happens automatically in most cases but you may need to trigger it yourself if you do something non-standard.



来源:https://stackoverflow.com/questions/2325768/when-is-uiview-drawrect-method-invoked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!