I am making an Cocoa app, using Core Animation to create custom UI. However, whenever I drag some layers around, they often leave some "residuals/traces" onto the other layers.
So far, my guess is that it is related to my usage of [setNeedsDisplay]. To my understanding, as I drag a layer around, I don't need to call this method to that layer (as nothing is updated within that layer). But the residuals that left behind are on other layers (so maybe they need to call that method? But then how do I know which layers the dragging mouse has passed over?)
For example, most the drawings are as simple as:
// Block view is a subclass of CALayer
@implementation BlockView
-(void)drawInContext:(CGContextRef)context
{
CGRect bounds = CGContextGetClipBoundingBox(context);
CGContextSetFillColorWithColor(context, color);
CGContextFillRect(context, bounds);
}
@end
However, sometimes I there are multiple levels of layers (3 max); but I don't think that's a issue.
I am wonder what could be a cause of this? This problem is difficult to show specific code examples, but some hints or possible guesses are welcome.