yyasynclayer 原理

一句话总结 YYAsyncLayer继承CALayer,在Runloop主线程空闲的时候通过后台线程异步将控件画出来

YYAsyncLayer主要包含三个类: YYAsyncLayer、YYSentinel、YYTransaction

YYTransaction

@interface YYTransaction()
@property (nonatomic, strong) id target;
@property (nonatomic, assign) SEL selector;
@end
static NSMutableSet *transactionSet = nil;

这个类其实可以看作是一个任务,其中包含 target接收者,和selector方法选择子。然后通过注册一个Runloop观察者,在Runloop 准备进入休眠退出的时候处理 已经保存的任务Set。