Когда я вызываю setNeedsDisplayInRect
для UIView
, и метод drawRect:
срабатывает, я несу ответственность за то, чтобы убедиться, что я не рендерирую вещи, которые находятся за пределами CGRect, который я вызвал, или фреймворк обработает это для меня ?
Пример:
-(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)];
}