Last active
August 29, 2015 13:56
-
-
Save peterlee0127/9131674 to your computer and use it in GitHub Desktop.
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
// Slide to unlock Animation | |
CALayer *maskLayer = [CALayer layer]; | |
maskLayer.backgroundColor = [[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.55f] CGColor]; | |
maskLayer.contents = (id)[[UIImage imageNamed:@"mask.png"] CGImage]; | |
maskLayer.contentsGravity = kCAGravityCenter; | |
maskLayer.frame = CGRectMake(self.frame.size.width * -1, 0.0f, self.frame.size.width * 2, self.frame.size.height); | |
CABasicAnimation *maskAnim = [CABasicAnimation animationWithKeyPath:@"position.x"]; | |
maskAnim.byValue = [NSNumber numberWithFloat:self.frame.size.width]; | |
maskAnim.repeatCount = HUGE_VAL; | |
maskAnim.duration = 2.0f; | |
[maskLayer addAnimation:maskAnim forKey:@"slideAnim"]; | |
self.layer.mask = maskLayer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment