Used for drawing, this method will be called at intiwithrect time.
The effect of this method is that when a touch event is available, it will be redrawn, and many of these buttons will have a more efficient effect. The following will be called
1. If the rect size is not set at UIView initialization, the drawrect will not be automatically called. The DrawRect is dropped after the Controller->loadview, Controller->viewdidload two method. So don't worry. In the controller, The drawrect of the view began to draw. This allows you to set some values in the controller to the view (if some variable values are needed for these view draw).
2, this method is called after calling SizeToFit, so you can call SizeToFit to calculate the size first. The system then automatically calls the DrawRect: method.
3, by setting the Contentmode property value to Uiviewcontentmoderedraw. The drawrect will be called automatically each time the frame is set or changed:.
4. Call Setneedsdisplay directly, or setneedsdisplayinrect: Trigger DrawRect:, but there is a precondition that rect cannot be 0.
What is the impact of using DrawRect