Created
May 4, 2018 02:36
-
-
Save zhangkn/1cf414bde15aa5205c3f97db81b3588e to your computer and use it in GitHub Desktop.
创建:CADisplayLink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property (nonatomic, strong) CADisplayLink *displayLink; | |
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleDisplayLink:)]; | |
// 每隔1帧调用一次 | |
self.displayLink.frameInterval = 1; //用来设置间隔多少帧调用一次`selector`方法,默认值是1,即每帧都调用一次。 | |
[self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; | |
//释放方法: | |
[self.displayLink invalidate]; //执行`invalidate`操作时,CADisplayLink对象就会从runloop中移除 | |
self.displayLink = nil; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment