Created
September 29, 2014 00:20
-
-
Save iosappdeveloper/f7beaf293ceb6fbc70e6 to your computer and use it in GitHub Desktop.
UIView border layer color with shadow animation
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
CALayer *layer = self.downloadContainerView.layer; | |
layer.shadowOffset = CGSizeMake(2, 2); | |
layer.shadowColor = [UIColor blackColor].CGColor; | |
layer.shadowRadius = 4.0f; | |
layer.shadowPath = [[UIBezierPath bezierPathWithRect:layer.bounds] CGPath]; | |
CABasicAnimation *color = [CABasicAnimation animationWithKeyPath:@"borderColor"]; | |
color.fromValue = (id)[UIColor redColor].CGColor; | |
color.toValue = (id)[UIColor lightGrayColor].CGColor; | |
self.downloadContainerView.layer.borderColor = [UIColor lightGrayColor].CGColor; | |
CABasicAnimation *shadowOpacity = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"]; | |
shadowOpacity.fromValue = @0.3; | |
shadowOpacity.toValue = @0; | |
self.downloadContainerView.layer.shadowOpacity = 0; | |
CAAnimationGroup *both = [CAAnimationGroup animation]; | |
both.duration = 1; | |
both.animations = @[color, shadowOpacity]; | |
both.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; | |
[self.downloadContainerView.layer addAnimation:both forKey:@"color and shadow"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment