-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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