Skip to content

Instantly share code, notes, and snippets.

@braker1nine
Last active May 31, 2016 13:11
Show Gist options
  • Save braker1nine/760ec2373123ea0594911258540070e7 to your computer and use it in GitHub Desktop.
Save braker1nine/760ec2373123ea0594911258540070e7 to your computer and use it in GitHub Desktop.
Fun with transforms
CGAffineTransform hideTransform = CGAffineTransformConcat(
CGAffineTransformMakeScale(0, 0),
CGAffineTransformMakeTranslation(
powerupButton.center.x - self.view.powerupView.center.x,
powerupButton.center.y - self.view.powerupView.center.y
)
);
[UIView animateWithDuration:0.3
delay:0
usingSpringWithDamping:0.7
initialSpringVelocity:0
options:0
animations:^
{
self.view.powerupView.transform = hideTransform;
self.view.powerupView.alpha = 0;
}
completion:^(BOOL finished)
{
self.view.powerupView.hidden = YES;
self.view.powerupView.transform = CGAffineTransformIdentity;
}];
CGAffineTransform hideTransform = CGAffineTransformConcat(
CGAffineTransformMakeScale(0.0001, 0.0001),
CGAffineTransformMakeTranslation(
powerupButton.center.x - self.view.powerupView.center.x,
powerupButton.center.y - self.view.powerupView.center.y
)
);
[UIView animateWithDuration:0.3
delay:0
usingSpringWithDamping:0.7
initialSpringVelocity:0
options:0
animations:^
{
self.view.powerupView.transform = hideTransform;
self.view.powerupView.alpha = 0;
}
completion:^(BOOL finished)
{
self.view.powerupView.hidden = YES;
self.view.powerupView.transform = CGAffineTransformIdentity;
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment