Skip to content

Instantly share code, notes, and snippets.

@xdream86
Created August 25, 2013 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdream86/6331790 to your computer and use it in GitHub Desktop.
Save xdream86/6331790 to your computer and use it in GitHub Desktop.
[self. ui_View.layer removeAllAnimations];
CABasicAnimation *pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
pulse.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
pulse.duration = 0.5 + (rand() % 10) * 0.05;
pulse.repeatCount = 1;
pulse.autoreverses = YES;
pulse.fromValue = [NSNumber numberWithFloat:.8];
pulse.toValue = [NSNumber numberWithFloat:1.2];
[self.ui_View.layer addAnimation:pulse forKey:nil];
// bounds
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"bounds"];
anim.duration = 1.f;
anim.fromValue = [NSValue valueWithCGRect:CGRectMake(0,0,10,10)];
anim.toValue = [NSValue valueWithCGRect:CGRectMake(10,10,200,200)];
anim.byValue = [NSValue valueWithCGRect:self. ui_View.bounds];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim.repeatCount = 1;
anim.autoreverses = YES;
[ui_View.layer addAnimation:anim forKey:nil];
//cornerRadius
CABasicAnimation *anim2 = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];
anim2.duration = 1.f;
anim2.fromValue = [NSNumber numberWithFloat:0.f];
anim2.toValue = [NSNumber numberWithFloat:20.f];
anim2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim2.repeatCount = CGFLOAT_MAX;
anim2.autoreverses = YES;
[ui_View.layer addAnimation:anim2 forKey:@"cornerRadius"];
//contentt
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"contents"];
anim.duration = 1.f;
anim.fromValue = (id)[UIImage imageNamed:@"1.jpg"].CGImage;
anim.toValue = (id)[UIImage imageNamed:@"2.png"].CGImage;
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim.repeatCount = CGFLOAT_MAX;
anim.autoreverses = YES;
[ui_View.layer addAnimation:anim forKey:nil];
CABasicAnimation *offsetAnimation = [CABasicAnimationanimationWithKeyPath:@"shadowOffset"];
offsetAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(15, 10)];
CABasicAnimation *radiusAnimation = [CABasicAnimationanimationWithKeyPath:@"shadowRadius"];
radiusAnimation.toValue = [NSNumber numberWithFloat:8];
CABasicAnimation *opacityAnimation = [CABasicAnimationanimationWithKeyPath:@"shadowOpacity"];
opacityAnimation.toValue = [NSNumber numberWithFloat:0.6];
CAAnimationGroup *group = [CAAnimationGroupanimation];
group.duration = 2;
group.repeatCount = 3;
group.autoreverses = YES;
group.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
group.animations = [NSArray arrayWithObjects:offsetAnimation,radiusAnimation, opacityAnimation, nil];
[_myLayeraddAnimation:group forKey:@"allMyAnimations"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment