Skip to content

Instantly share code, notes, and snippets.

@7imbrook
Created June 29, 2013 18:19
Show Gist options
  • Save 7imbrook/19acd006e4ac361131c8 to your computer and use it in GitHub Desktop.
Save 7imbrook/19acd006e4ac361131c8 to your computer and use it in GitHub Desktop.
One of the more interesting ways I've found to animate views together.
CGRect endFrame1 = [_inputFields[0] frame];
CGRect endFrame2 = [_inputFields[1] frame];
CGRect startFrame1 = endFrame1;
CGRect startFrame2 = endFrame2;
startFrame1.origin.y -= 100;
startFrame2.origin.y -= 50;
CGRect *start = calloc(2, sizeof(CGRect));
start[0] = startFrame1;
start[1] = startFrame2;
CGRect *end = calloc(2, sizeof(CGRect));
end[0] = endFrame1;
end[1] = endFrame2;
[_inputFields enumerateObjectsUsingBlock:^(UITextField *obj, NSUInteger idx, BOOL *stop) {
[obj setFrame:start[idx]];
[obj setAlpha:0.0];
}];
[UIView animateWithDuration:0.6 delay:0.0 usingSpringWithDamping:1.0 initialSpringVelocity:0.5 options:UIViewAnimationOptionCurveEaseIn animations:^{
[_inputFields enumerateObjectsUsingBlock:^(UITextField *obj, NSUInteger idx, BOOL *stop) {
[obj setFrame:end[idx]];
[obj setAlpha:1.0];
}];
} completion:^(BOOL finished) {
free(start);
free(end);
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment