Last active
December 20, 2015 17:59
-
-
Save eyeplum/c943c07c135ddc4edc00 to your computer and use it in GitHub Desktop.
CVDisplayLink based animator example.
This file contains hidden or 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
CVReturn displayLinkOutputCallback( | |
CVDisplayLinkRef displayLink, | |
const CVTimeStamp *inNow, | |
const CVTimeStamp *inOutputTime, | |
CVOptionFlags flagsIn, | |
CVOptionFlags *flagsOut, | |
void *displayLinkContext) | |
{ | |
@autoreleasepool { | |
Animator *self = (__bridge Animator *)displayLinkContext; | |
[self animate]; | |
} | |
return kCVReturnSuccess; | |
} | |
- (void)animate { | |
// Animate | |
} | |
- (void)performRotate { | |
self.currentAngel += kRotationAngle; | |
self.coverImageLayer.transform = CATransform3DMakeRotation(self.currentAngel, 0, 0, 1); | |
} | |
- (void)awakeFromNib { | |
CVDisplayLinkCreateWithActiveCGDisplays(&displayLinkRef); | |
CVDisplayLinkSetOutputCallback(displayLinkRef, displayLinkOutputCallback, (__bridge void *)self); | |
CVDisplayLinkStart(displayLinkRef); | |
} | |
- (void)dealloc { | |
CVDisplayLinkStop(displayLinkRef); | |
CVDisplayLinkRelease(displayLinkRef); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment