I am responsible for cropping when doing individual rendering with drawRect :?

When I call setNeedsDisplayInRectin UIViewand the method fires drawRect:, am I responsible for making sure that I don’t represent the material that is outside of the CGRect that I called, or will handle the framework for me?

Example:

-(void)drawRect:(CGRect)rect
{
    //assume this is called through someMethod below
    CGContextRef ctx = UIGraphicsGetCurrentContext();      
    [[UIColor redColor] setFill];
    CGContextFillRect(ctx, rect);
    [[UIColor blueColor] setFill];
    // is this following line a no-op? or should I check to make sure the rect
    // I am making is contained within the rect that is passed in?
    CGContextFillRect(ctx, CGRectMake(100.0f, 100.0f, 25.0f, 25.0f));      
}

-(void)someMethod
{
    [self setNeedsDisplayInRect:CGRectMake(50.0f, 50.0f, 25.0f, 25.0f)];
}
+3
source share
2 answers

. OS X (AppKit) NSView ( 10.3). , UIKit. , , , , , , .

+2

, : , .

rect, , , .

, , , , , .

+3

Source: https://habr.com/ru/post/1703774/


All Articles