请教,比如我要自定义一个view,该view实现异步绘制,是不是如下处理呢:
@implementation AsyncDrawingView
-(void)displayLayer:(CALayer *)layer
{
CGContextRef context = CGBitmapContextCreate(...);
........
CGImageRef imageRef = CGBitmapContextCreateImage(context);
dispatch_async(dispatch_get_main_queue(), ^{
layer.contents = imageRef;
});
}
@end