Skip to content

Instantly share code, notes, and snippets.

@bartolsthoorn
Created March 9, 2013 19:27
Show Gist options
  • Save bartolsthoorn/5125418 to your computer and use it in GitHub Desktop.
Save bartolsthoorn/5125418 to your computer and use it in GitHub Desktop.
openMainMenu works properly and animates the view in, closeMainMenu does not animate..
- (void)openMainMenu {
_menu_opened = YES;
_darknessOverlay.hidden = NO;
CGRect oldFrame = _menuView.frame;
CGRect f = _menuView.frame;
f.origin.x = _menuView.frame.size.width * -1;
_menuView.frame = f;
_menuView.hidden = NO;
[UIView animateWithDuration:0.3
animations:^{
_menuView.frame = oldFrame;
}];
[self.leftMenuButton setImage:[UIImage imageNamed:@"home-back"] forState:UIControlStateNormal];
}
- (void)closeMainMenu {
_menu_opened = NO;
_darknessOverlay.hidden = YES;
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
CGRect f = _menuView.frame;
f.origin.x = _menuView.frame.size.width * -1;
_menuView.frame = f;
} completion:nil];
[self.leftMenuButton setImage:[UIImage imageNamed:@"home"] forState:UIControlStateNormal];
}
- (IBAction)leftMenuButtonTouched:(id)sender {
if (_menu_opened == NO) {
[self openMainMenu];
} else {
[self closeMainMenu];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment