Skip to content

Instantly share code, notes, and snippets.

@mamaz
Last active June 30, 2016 13:32
Show Gist options
  • Save mamaz/61077aabaceb43b941e5 to your computer and use it in GitHub Desktop.
Save mamaz/61077aabaceb43b941e5 to your computer and use it in GitHub Desktop.
Animate using Autolayout the correct way
// source:
// http://stackoverflow.com/a/12664093/1328982
// credits to: Gervasio Marchand
- (void)moveBannerOffScreen {
[self.view layoutIfNeeded];
[self.childView mas_remakeConstraints:(MASConstraint* make){
make.top.mas_equal(0);
make.left.mas_equal(0);
make.right.mas_equal(320);
make.bottom.mas_equal(0);
}];
[UIView animateWithDuration:5
animations:^{
[self.view layoutIfNeeded]; // Called on parent view
}];
bannerIsVisible = FALSE;
}
- (void)moveBannerOnScreen {
[self.view layoutIfNeeded];
[self.childView mas_remakeConstraints:(MASConstraint* make){
make.top.mas_equal(0);
make.left.mas_equal(0);
make.right.mas_equal(0);
make.bottom.mas_equal(0);
}];
[UIView animateWithDuration:5
animations:^{
[self.view layoutIfNeeded]; // Called on parent view
}];
bannerIsVisible = TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment