drawRect introduce

来源:互联网 发布:C语言求主析取范式 编辑:程序博客网 时间:2024/05/21 07:13

drawRect:
Draws the receiver’s image within the passed-in rectangle.
- (void)drawRect:(CGRect)rect
Parameters
rect
A rectangle defining the area to restrict drawing to.
Discussion
Subclasses override this method if they actually draw their views. Subclasses need not override this method if the subclass is a container for other views. The default implementation does nothing. If your custom view is a direct UIView subclass, you do not need to call the implementation of super. Note that it is the responsibility of each subclass to totally fill rect if its superclass’s implementation actually draws and opaqueis YES.
When this method is invoked, the receiver can assume the coordinate transformations of its frame and bounds rectangles have been applied; all it needs to do is invoke rendering client functions. Use the UIGraphicsGetCurrentContext function to get the current graphics context for drawing that also has the coordinate origin in the upper-left corner. Do not retain the graphics context since it can change between calls to thedrawRect: method.
Availability
Available in iPhone OS 2.0 and later.
See Also
– setNeedsDisplay
– setNeedsDisplayInRect:
  @property contentMode
Declared In
UIView.h