实现异步,无非三种:用线程(比如GCD)、Runloop、CADisplayLink
- (void)display {
dispatch_async(backgroundQueue, ^{
CGContextRef ctx = CGBitmapContextCreate(...);
// draw in context...
CGImageRef img = CGBitmapContextCreateImage(ctx);
CFRelease(ctx);
dispatch_async(mainQueue, ^{
layer.contents = img;
});
});
}
Q:
- AsyncDisplayKit异步加载的原理
- YYAsyncLayer异步加载的原理
-
SDWebImage如何做到异步加载的
用NSCache做内存缓存 - AFNetworking的UIImageView如何做到异步加载的
- YTKNetwork
网友评论