Skip to content

Instantly share code, notes, and snippets.

@natbro
Created February 3, 2015 13:18
Show Gist options
  • Save natbro/bbf150ba921f6abfd7ae to your computer and use it in GitHub Desktop.
Save natbro/bbf150ba921f6abfd7ae to your computer and use it in GitHub Desktop.
-(void)alertPulse {
// ios7+-style UIAlertView drop-and-bounce. if starting hidden, fade in from quite big & fade in until completion,
// otherwise pulse up then back with default ease-in/-out to look springy, no fading
BOOL wasHidden = NO;
if (self.hidden == YES) {
wasHidden = YES;
self.alpha = 0.0;
self.transform = CGAffineTransformMakeScale(1.5, 1.5);
}
self.hidden = NO;
[UIView animateWithDuration:0.2
animations:^{
self.transform = CGAffineTransformMakeScale(1.05, 1.05);
if (wasHidden) { self.alpha = 0.8; }
}
completion:^(BOOL finished) {
[UIView animateWithDuration:1/7.5
animations:^{
self.transform = CGAffineTransformIdentity;
self.alpha = 1.0;
}];
}];
#if 0
// pre-ios7-style UIAlertView grow-and-bounce. if starting hidden, fade in from quite small & fade in until completion,
// otherwise pulse up then back with default ease-in/-out to look springy, no fading
if (self.hidden == YES) {
wasHidden = YES;
self.alpha = 0.0;
self.transform = CGAffineTransformMakeScale(0.6, 0.6);
}
self.hidden = NO;
[UIView animateWithDuration:0.2
animations:^{
self.transform = CGAffineTransformMakeScale(1.05, 1.05);
if (wasHidden) { self.alpha = 0.8; }
}
completion:^(BOOL finished){
[UIView animateWithDuration:1/15.0
animations:^{
self.transform = CGAffineTransformMakeScale(0.9, 0.9);
if (wasHidden) { self.alpha = 0.9; }
}
completion:^(BOOL finished) {
[UIView animateWithDuration:1/7.5
animations:^{
self.transform = CGAffineTransformIdentity; self.alpha = 1.0;
}
];
}
];
}
];
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment