Last active
June 30, 2016 13:32
-
-
Save mamaz/61077aabaceb43b941e5 to your computer and use it in GitHub Desktop.
Animate using Autolayout the correct way
This file contains hidden or 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
// 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