2:
, subviews , dueto. , , , , , :
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
contentView.frame = CGRectMake(CGRectGetWidth(sidebarView.frame), 0, contentView.frame.size.width-CGRectGetWidth(sidebarView.frame), contentView.frame.size.height);
}
- (void)animationDidStopBack:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
contentView.frame = contentView.bounds;
}
- (void)revealSidebar:(BOOL)shouldReveal {
if (shouldReveal) {
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:0.1];
[UIView setAnimationDelegate:self];
contentView.frame = CGRectOffset(contentView.bounds, CGRectGetWidth(sidebarView.frame), 0);
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];
} else {
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
contentView.frame = CGRectMake(0, 0, contentView.frame.size.width+CGRectGetWidth(sidebarView.frame), contentView.frame.size.height);
[UIView setAnimationDidStopSelector:@selector(animationDidStopBack:finished:context:)];
[UIView commitAnimations];
}
_state.isShowing = shouldReveal ? 1 : 0;
}
, , - . , .
1:
:
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:0.3];
if (shouldReveal) {
contentView.frame = CGRectMake(CGRectGetWidth(sidebarView.frame), 0, contentView.frame.size.width-CGRectGetWidth(sidebarView.frame), contentView.frame.size.height);
} else {
contentView.frame = CGRectMake(0, 0, contentView.frame.size.width+CGRectGetWidth(sidebarView.frame), contentView.frame.size.height);
}
[UIView commitAnimations];
:
/ , x-, . , , :
- (void)revealSidebar:(BOOL)shouldReveal {
if (shouldReveal) {
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:0.3];
contentView.transform = CGAffineTransformTranslate(contentView.transform, CGRectGetWidth(sidebarView.frame), 0);
contentView.frame = CGRectMake(contentView.frame.origin.x, contentView.frame.origin.y, contentView.frame.size.width-sidebarView.frame.size.width, contentView.frame.size.height);
[UIView commitAnimations];
} else {
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:0.3];
contentView.frame = CGRectMake(sidebarView.frame.size.width, contentView.frame.origin.y, contentView.frame.size.width-sidebarView.frame.size.width, contentView.frame.size.height);
[UIView commitAnimations];
}
_state.isShowing = shouldReveal ? 1 : 0;
}
, :
contentView.frame = CGRectMake(sidebarView.frame.size.width+(contentView.frame.size.width/2), contentView.frame.origin.y, contentView.frame.size.width-sidebarView.frame.size.width, contentView.frame.size.height);