123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #import "SidebarLuvocracyAnimation.h"
-
- @implementation SidebarLuvocracyAnimation
-
- + (void)animateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
- {
- [self resetSidebarPosition:sidebarView];
- [self resetContentPosition:contentView];
-
-
- CATransform3D contentTransform = CATransform3DIdentity;
- contentTransform.m34 = -1.0f / 800.0f;
- contentView.layer.zPosition = 100;
-
-
- CATransform3D sidebarTransform = CATransform3DIdentity;
- sidebarTransform = CATransform3DScale(sidebarTransform, 1.7, 1.7, 1.7);
- sidebarView.layer.transform = sidebarTransform;
-
- sidebarTransform = CATransform3DIdentity;
- sidebarTransform = CATransform3DScale(sidebarTransform, 1.0, 1.0, 1.0);
-
- if(side == LeftSide)
- {
- contentTransform = CATransform3DTranslate(contentTransform, visibleWidth - (contentView.frame.size.width / 2 * 0.4), 0.0, 0.0);
- contentTransform = CATransform3DScale(contentTransform, 0.6, 0.6, 0.6);
- }
- else
- {
- contentTransform = CATransform3DTranslate(contentTransform, 0 - visibleWidth + (contentView.frame.size.width / 2 * 0.4), 0.0, 0.0);
- contentTransform = CATransform3DScale(contentTransform, 0.6, 0.6, 0.6);
- }
-
- UIView *overlayContentView = [self overlayContentView:contentView.bounds];
- [contentView addSubview:overlayContentView];
-
-
- [UIView animateWithDuration:animationDuration
- delay:0.0
- options:UIViewAnimationOptionCurveEaseInOut
- animations:^{
- contentView.layer.transform = contentTransform;
- sidebarView.layer.transform = sidebarTransform;
- overlayContentView.backgroundColor = [self overlayContentColor];
- }
- completion:^(BOOL finished) {
- completion(finished);
- }];
- }
-
-
- + (void)reverseAnimateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
- {
-
- CATransform3D contentTransform = CATransform3DIdentity;
- contentTransform.m34 = -1.0f / 800.0f;
- contentView.layer.zPosition = 100;
- contentTransform = CATransform3DTranslate(contentTransform, 0.0, 0.0, 0.0);
- contentTransform = CATransform3DScale(contentTransform, 1.0, 1.0, 1.0);
-
-
- __block CATransform3D sidebarTransform = CATransform3DIdentity;
- sidebarTransform = CATransform3DScale(sidebarTransform, 1.7, 1.7, 1.7);
-
- UIView *overlayContentView = [self overlayContentView:contentView.bounds];
- [contentView addSubview:overlayContentView];
-
-
- [UIView animateWithDuration:animationDuration
- delay:0.0
- options:UIViewAnimationOptionCurveEaseInOut
- animations:^{
- contentView.layer.transform = contentTransform;
- sidebarView.layer.transform = sidebarTransform;
- overlayContentView.backgroundColor = [UIColor clearColor];
- }
- completion:^(BOOL finished) {
- completion(finished);
- sidebarTransform = CATransform3DIdentity;
- sidebarTransform = CATransform3DScale(sidebarTransform, 1.0, 1.0, 1.0);
- sidebarView.layer.transform = sidebarTransform;
- [overlayContentView removeFromSuperview];
- }];
- }
-
-
- @end
|