Skip to content

Instantly share code, notes, and snippets.

@natbro
Created February 3, 2015 13:10
Show Gist options
  • Save natbro/8d43be770aecac172724 to your computer and use it in GitHub Desktop.
Save natbro/8d43be770aecac172724 to your computer and use it in GitHub Desktop.
@implementation UIView (Pulse)
- (void)pulseOnce
{
[self pulse:NO];
}
- (void)pulse:(BOOL)repeats
{
CGAffineTransform initialTransform = CGAffineTransformIdentity; // self.transform;
[UIView animateWithDuration:0.2
delay:0.0
options:(repeats ? UIViewAnimationOptionRepeat : 0)
animations:^{
self.transform = CGAffineTransformConcat(initialTransform, CGAffineTransformMakeScale(1.05, 1.05));
}
completion:^(BOOL finished){
[UIView animateWithDuration:1/15.0
animations:^{
self.transform = CGAffineTransformConcat(initialTransform, CGAffineTransformMakeScale(0.9, 0.9));
}
completion:^(BOOL finished) {
[UIView animateWithDuration:1/7.5
animations:^{
self.transform = initialTransform;
}
];
}
];
}
];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment