享受 UIView 动画和 UIView 翻转的乐趣

发布于 2024-12-22 16:45:26 字数 8575 浏览 1 评论 0原文

(我对长篇文章表示歉意)为了使我的 AQGridView 更加生动,附加的代码将选定的单元格复制到 UIView 中,然后将该视图动画化以扩展以填充屏幕,然后将视图转换为看起来像全屏封面动画。随意重用,但这不是我的问题。我的问题是景观的动画,它一定是不同的。我希望将我的单元格视图设置为屏幕右半部分的动画,并展开以填充屏幕的右半部分(已完成),然后让它在屏幕上向左侧翻转旋转。锚点位于 CGPointMake(0.5, 0.5);不起作用,将平移 x 值设置为屏幕的一半并再次返回也不起作用,它只是执行,然后飞离屏幕!帮助!!

编辑:(由于我没有意识到我已经将新的 UIView's 添加到 self.navigationController.view 属性,所以代码现在正在工作,所以所要做的就是渲染并翻转它,无需翻译!) 工作代码:

if(UIInterfaceOrientationIsPortrait(viewController.interfaceOrientation)) {
            self.view.userInteractionEnabled = NO;

            [self.navigationController.view addSubview:viewForCopy];
            [self.navigationController.view bringSubviewToFront:viewForCopy];
            [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)];
            [viewForCopy setAlpha:1.0f];

            [[_gridView cellForItemAtIndex:index] setAlpha:0.0f];

            [UIView animateWithDuration:1.5f
                                  delay:0.0f
                                options:UIViewAnimationCurveEaseInOut
                             animations:^{
                                 [self.navigationController.navigationBar setAlpha:0.0f];
                                 [newShadow removeFromSuperlayer];
                                 [viewForCopy setFrame:CGRectMake(-158, 10, self.view.bounds.size.width * 1.55, self.view.bounds.size.height * 1.25)];
                                 [self.navigationController.navigationBar setAlpha:0.0f];  
                             } 
                             completion:^(BOOL finished) {
                                 [UIView animateWithDuration:2.0f
                                                       delay:0.0f
                                                     options:UIViewAnimationCurveEaseInOut
                                                  animations:^{
                                                      [viewForCopy setAlpha:0.0f];
                                                      CATransform3D _3Dt = CATransform3DIdentity;
                                                      _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width * -1, 0, 0);
                                                      _3Dt = CATransform3DRotate(_3Dt, M_PI / -2.0f, 0.0f, 0.1f, 0.0f);  
                                                      _3Dt.m34 = 1.0f / 500.0f;
                                                      _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width, 0, 0);
                                                      viewForCopy.layer.transform = _3Dt;
                                                      [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES];
                                                      [self.navigationController pushViewController:viewController animated:NO];

                                                  } 
                                                  completion:^(BOOL finished) {
                                                  }];
                                 [[_gridView cellForItemAtIndex:index] setAlpha:1.0f];
                                 [self.navigationController.view sendSubviewToBack:viewForCopy];

                             }];
        }
             else if(UIInterfaceOrientationIsLandscape(viewController.interfaceOrientation)){
                 UIView *viewforCopyLandscape2 = [[[UIView alloc]initWithFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)]autorelease];
                 viewforCopyLandscape2.backgroundColor = [UIColor whiteColor];
                 viewforCopyLandscape2.alpha = 0.0f;

                 [self.navigationController.view addSubview:viewforCopyLandscape2];
                 [self.navigationController.view bringSubviewToFront:viewforCopyLandscape2];
                 [self.navigationController.view addSubview:viewForCopy];
                 [self.navigationController.view bringSubviewToFront:viewForCopy];

                 [newShadow removeFromSuperlayer];

                 [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)];

                 [[_gridView cellForItemAtIndex:index] setAlpha:0.0f];

                 self.view.userInteractionEnabled = NO;

                 [UIView animateWithDuration:1.5f
                                       delay:0.0f
                                     options:UIViewAnimationCurveEaseInOut
                                  animations:^{
                                      [viewforCopyLandscape2 setFrame:CGRectMake(0, 20, self.view.bounds.size.width/2, self.view.bounds.size.height)];
                                      [viewForCopy setFrame:CGRectMake(407, 10, self.view.bounds.size.width * .78, self.view.bounds.size.height * 1.25)];
                                      [self.navigationController.navigationBar setAlpha:0.0f];  
                                      viewforCopyLandscape2.alpha = 1.0f;
                                  } 
                                  completion:^(BOOL finished) {

                                      UIView *viewForCopyLandscape = [[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height)]autorelease];
                                      UIGraphicsBeginImageContext(CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height));
                                      [self.navigationController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
                                      UIImageView *viewImage = [[[UIImageView alloc]initWithImage:UIGraphicsGetImageFromCurrentImageContext()]autorelease];
                                      UIGraphicsEndImageContext();
                                      viewForCopyLandscape = viewImage;
                                      [self.navigationController.view addSubview:viewForCopyLandscape];
                                      [self.navigationController.view bringSubviewToFront:viewForCopyLandscape];

                                      [viewForCopy setAlpha:0.0f];
                                      [UIView animateWithDuration:2.0f
                                                            delay:0.0f
                                                          options:UIViewAnimationCurveEaseInOut
                                                       animations:^{

                                                           CATransform3D transform = CATransform3DMakeRotation(-M_PI / 1.1, 0.0, 1.0, 0.0);
                                                           transform.m34 = 1.0f / 2500.0f;
                                                           viewForCopyLandscape.layer.transform = transform;

                                                           [self.navigationController.view sendSubviewToBack:viewForCopy];
                                                           [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES];
                                                           [self.navigationController pushViewController:viewController animated:NO];
                                                           [viewforCopyLandscape2 removeFromSuperview];

                                                       }           
                                                       completion:^(BOOL finished) {
                                                           [[_gridView cellForItemAtIndex:index] setAlpha:1.0f];
                                                           [viewForCopy removeFromSuperview];
                                                           [UIView animateWithDuration:1.00 animations:^ {
                                                               [viewForCopyLandscape setAlpha:0.0f];

                                                           }];
                                                       }];
                                  }];
}

(My apologies for the long post) To jazz up my AQGridView, the attached code copies the selected cell into a UIView, then animates that view to expand to fill the screen, then have said view transform to look like a full screen cover animation. Feel free to reuse, but that's not my problem. My problem is the animation for Landscape, which must be different. I wish to animate my cell view to the right half of the screen and expand to fill the right half of the screen (already accomplished) then have it do a y flip rotation across the screen to the left side. Anchor points at CGPointMake(0.5, 0.5); don't work, and neither does setting the translate x value to half of the screen and back again, it just performs, then flies off the screen! HELP!!

EDIT: (The code is now working thanks to me not realizing that I had been adding the new UIView's to the self.navigationController.view property, so all it took was to render that and flip it, no translations needed!)
WORKING CODE:

if(UIInterfaceOrientationIsPortrait(viewController.interfaceOrientation)) {
            self.view.userInteractionEnabled = NO;

            [self.navigationController.view addSubview:viewForCopy];
            [self.navigationController.view bringSubviewToFront:viewForCopy];
            [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)];
            [viewForCopy setAlpha:1.0f];

            [[_gridView cellForItemAtIndex:index] setAlpha:0.0f];

            [UIView animateWithDuration:1.5f
                                  delay:0.0f
                                options:UIViewAnimationCurveEaseInOut
                             animations:^{
                                 [self.navigationController.navigationBar setAlpha:0.0f];
                                 [newShadow removeFromSuperlayer];
                                 [viewForCopy setFrame:CGRectMake(-158, 10, self.view.bounds.size.width * 1.55, self.view.bounds.size.height * 1.25)];
                                 [self.navigationController.navigationBar setAlpha:0.0f];  
                             } 
                             completion:^(BOOL finished) {
                                 [UIView animateWithDuration:2.0f
                                                       delay:0.0f
                                                     options:UIViewAnimationCurveEaseInOut
                                                  animations:^{
                                                      [viewForCopy setAlpha:0.0f];
                                                      CATransform3D _3Dt = CATransform3DIdentity;
                                                      _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width * -1, 0, 0);
                                                      _3Dt = CATransform3DRotate(_3Dt, M_PI / -2.0f, 0.0f, 0.1f, 0.0f);  
                                                      _3Dt.m34 = 1.0f / 500.0f;
                                                      _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width, 0, 0);
                                                      viewForCopy.layer.transform = _3Dt;
                                                      [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES];
                                                      [self.navigationController pushViewController:viewController animated:NO];

                                                  } 
                                                  completion:^(BOOL finished) {
                                                  }];
                                 [[_gridView cellForItemAtIndex:index] setAlpha:1.0f];
                                 [self.navigationController.view sendSubviewToBack:viewForCopy];

                             }];
        }
             else if(UIInterfaceOrientationIsLandscape(viewController.interfaceOrientation)){
                 UIView *viewforCopyLandscape2 = [[[UIView alloc]initWithFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)]autorelease];
                 viewforCopyLandscape2.backgroundColor = [UIColor whiteColor];
                 viewforCopyLandscape2.alpha = 0.0f;

                 [self.navigationController.view addSubview:viewforCopyLandscape2];
                 [self.navigationController.view bringSubviewToFront:viewforCopyLandscape2];
                 [self.navigationController.view addSubview:viewForCopy];
                 [self.navigationController.view bringSubviewToFront:viewForCopy];

                 [newShadow removeFromSuperlayer];

                 [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)];

                 [[_gridView cellForItemAtIndex:index] setAlpha:0.0f];

                 self.view.userInteractionEnabled = NO;

                 [UIView animateWithDuration:1.5f
                                       delay:0.0f
                                     options:UIViewAnimationCurveEaseInOut
                                  animations:^{
                                      [viewforCopyLandscape2 setFrame:CGRectMake(0, 20, self.view.bounds.size.width/2, self.view.bounds.size.height)];
                                      [viewForCopy setFrame:CGRectMake(407, 10, self.view.bounds.size.width * .78, self.view.bounds.size.height * 1.25)];
                                      [self.navigationController.navigationBar setAlpha:0.0f];  
                                      viewforCopyLandscape2.alpha = 1.0f;
                                  } 
                                  completion:^(BOOL finished) {

                                      UIView *viewForCopyLandscape = [[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height)]autorelease];
                                      UIGraphicsBeginImageContext(CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height));
                                      [self.navigationController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
                                      UIImageView *viewImage = [[[UIImageView alloc]initWithImage:UIGraphicsGetImageFromCurrentImageContext()]autorelease];
                                      UIGraphicsEndImageContext();
                                      viewForCopyLandscape = viewImage;
                                      [self.navigationController.view addSubview:viewForCopyLandscape];
                                      [self.navigationController.view bringSubviewToFront:viewForCopyLandscape];

                                      [viewForCopy setAlpha:0.0f];
                                      [UIView animateWithDuration:2.0f
                                                            delay:0.0f
                                                          options:UIViewAnimationCurveEaseInOut
                                                       animations:^{

                                                           CATransform3D transform = CATransform3DMakeRotation(-M_PI / 1.1, 0.0, 1.0, 0.0);
                                                           transform.m34 = 1.0f / 2500.0f;
                                                           viewForCopyLandscape.layer.transform = transform;

                                                           [self.navigationController.view sendSubviewToBack:viewForCopy];
                                                           [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES];
                                                           [self.navigationController pushViewController:viewController animated:NO];
                                                           [viewforCopyLandscape2 removeFromSuperview];

                                                       }           
                                                       completion:^(BOOL finished) {
                                                           [[_gridView cellForItemAtIndex:index] setAlpha:1.0f];
                                                           [viewForCopy removeFromSuperview];
                                                           [UIView animateWithDuration:1.00 animations:^ {
                                                               [viewForCopyLandscape setAlpha:0.0f];

                                                           }];
                                                       }];
                                  }];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄情伤 2024-12-29 16:45:26

由于我没有意识到我已经将新的 UIView 添加到 self.navigationController.view 属性中,因此代码现在可以正常工作,因此只需渲染并翻转它,无需翻译!)

if(UIInterfaceOrientationIsPortrait(viewController.interfaceOrientation)) {
            self.view.userInteractionEnabled = NO;

            [self.navigationController.view addSubview:viewForCopy];
            [self.navigationController.view bringSubviewToFront:viewForCopy];
            [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)];
            [viewForCopy setAlpha:1.0f];

            [[_gridView cellForItemAtIndex:index] setAlpha:0.0f];

            [UIView animateWithDuration:1.5f
                                  delay:0.0f
                                options:UIViewAnimationCurveEaseInOut
                             animations:^{
                                 [self.navigationController.navigationBar setAlpha:0.0f];
                                 [newShadow removeFromSuperlayer];
                                 [viewForCopy setFrame:CGRectMake(-158, 10, self.view.bounds.size.width * 1.55, self.view.bounds.size.height * 1.25)];
                                 [self.navigationController.navigationBar setAlpha:0.0f];  
                             } 
                             completion:^(BOOL finished) {
                                 [UIView animateWithDuration:2.0f
                                                       delay:0.0f
                                                     options:UIViewAnimationCurveEaseInOut
                                                  animations:^{
                                                      [viewForCopy setAlpha:0.0f];
                                                      CATransform3D _3Dt = CATransform3DIdentity;
                                                      _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width * -1, 0, 0);
                                                      _3Dt = CATransform3DRotate(_3Dt, M_PI / -2.0f, 0.0f, 0.1f, 0.0f);  
                                                      _3Dt.m34 = 1.0f / 500.0f;
                                                      _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width, 0, 0);
                                                      viewForCopy.layer.transform = _3Dt;
                                                      [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES];
                                                      [self.navigationController pushViewController:viewController animated:NO];

                                                  } 
                                                  completion:^(BOOL finished) {
                                                  }];
                                 [[_gridView cellForItemAtIndex:index] setAlpha:1.0f];
                                 [self.navigationController.view sendSubviewToBack:viewForCopy];

                             }];
        }
             else if(UIInterfaceOrientationIsLandscape(viewController.interfaceOrientation)){
                 UIView *viewforCopyLandscape2 = [[[UIView alloc]initWithFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)]autorelease];
                 viewforCopyLandscape2.backgroundColor = [UIColor whiteColor];
                 viewforCopyLandscape2.alpha = 0.0f;

                 [self.navigationController.view addSubview:viewforCopyLandscape2];
                 [self.navigationController.view bringSubviewToFront:viewforCopyLandscape2];
                 [self.navigationController.view addSubview:viewForCopy];
                 [self.navigationController.view bringSubviewToFront:viewForCopy];

                 [newShadow removeFromSuperlayer];

                 [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)];

                 [[_gridView cellForItemAtIndex:index] setAlpha:0.0f];

                 self.view.userInteractionEnabled = NO;

                 [UIView animateWithDuration:1.5f
                                       delay:0.0f
                                     options:UIViewAnimationCurveEaseInOut
                                  animations:^{
                                      [viewforCopyLandscape2 setFrame:CGRectMake(0, 20, self.view.bounds.size.width/2, self.view.bounds.size.height)];
                                      [viewForCopy setFrame:CGRectMake(407, 10, self.view.bounds.size.width * .78, self.view.bounds.size.height * 1.25)];
                                      [self.navigationController.navigationBar setAlpha:0.0f];  
                                      viewforCopyLandscape2.alpha = 1.0f;
                                  } 
                                  completion:^(BOOL finished) {

                                      UIView *viewForCopyLandscape = [[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height)]autorelease];
                                      UIGraphicsBeginImageContext(CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height));
                                      [self.navigationController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
                                      UIImageView *viewImage = [[[UIImageView alloc]initWithImage:UIGraphicsGetImageFromCurrentImageContext()]autorelease];
                                      UIGraphicsEndImageContext();
                                      viewForCopyLandscape = viewImage;
                                      [self.navigationController.view addSubview:viewForCopyLandscape];
                                      [self.navigationController.view bringSubviewToFront:viewForCopyLandscape];

                                      [viewForCopy setAlpha:0.0f];
                                      [UIView animateWithDuration:2.0f
                                                            delay:0.0f
                                                          options:UIViewAnimationCurveEaseInOut
                                                       animations:^{

                                                           CATransform3D transform = CATransform3DMakeRotation(-M_PI / 1.1, 0.0, 1.0, 0.0);
                                                           transform.m34 = 1.0f / 2500.0f;
                                                           viewForCopyLandscape.layer.transform = transform;

                                                           [self.navigationController.view sendSubviewToBack:viewForCopy];
                                                           [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES];
                                                           [self.navigationController pushViewController:viewController animated:NO];
                                                           [viewforCopyLandscape2 removeFromSuperview];

                                                       }           
                                                       completion:^(BOOL finished) {
                                                           [[_gridView cellForItemAtIndex:index] setAlpha:1.0f];
                                                           [viewForCopy removeFromSuperview];
                                                           [UIView animateWithDuration:1.00 animations:^ {
                                                               [viewForCopyLandscape setAlpha:0.0f];

                                                           }];
                                                       }];
                                  }];
}

The code is now working thanks to me not realizing that I had been adding the new UIView's to the self.navigationController.view property, so all it took was to render that and flip it, no translations needed!)

if(UIInterfaceOrientationIsPortrait(viewController.interfaceOrientation)) {
            self.view.userInteractionEnabled = NO;

            [self.navigationController.view addSubview:viewForCopy];
            [self.navigationController.view bringSubviewToFront:viewForCopy];
            [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)];
            [viewForCopy setAlpha:1.0f];

            [[_gridView cellForItemAtIndex:index] setAlpha:0.0f];

            [UIView animateWithDuration:1.5f
                                  delay:0.0f
                                options:UIViewAnimationCurveEaseInOut
                             animations:^{
                                 [self.navigationController.navigationBar setAlpha:0.0f];
                                 [newShadow removeFromSuperlayer];
                                 [viewForCopy setFrame:CGRectMake(-158, 10, self.view.bounds.size.width * 1.55, self.view.bounds.size.height * 1.25)];
                                 [self.navigationController.navigationBar setAlpha:0.0f];  
                             } 
                             completion:^(BOOL finished) {
                                 [UIView animateWithDuration:2.0f
                                                       delay:0.0f
                                                     options:UIViewAnimationCurveEaseInOut
                                                  animations:^{
                                                      [viewForCopy setAlpha:0.0f];
                                                      CATransform3D _3Dt = CATransform3DIdentity;
                                                      _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width * -1, 0, 0);
                                                      _3Dt = CATransform3DRotate(_3Dt, M_PI / -2.0f, 0.0f, 0.1f, 0.0f);  
                                                      _3Dt.m34 = 1.0f / 500.0f;
                                                      _3Dt = CATransform3DTranslate(_3Dt, viewForCopy.frame.size.width, 0, 0);
                                                      viewForCopy.layer.transform = _3Dt;
                                                      [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES];
                                                      [self.navigationController pushViewController:viewController animated:NO];

                                                  } 
                                                  completion:^(BOOL finished) {
                                                  }];
                                 [[_gridView cellForItemAtIndex:index] setAlpha:1.0f];
                                 [self.navigationController.view sendSubviewToBack:viewForCopy];

                             }];
        }
             else if(UIInterfaceOrientationIsLandscape(viewController.interfaceOrientation)){
                 UIView *viewforCopyLandscape2 = [[[UIView alloc]initWithFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)]autorelease];
                 viewforCopyLandscape2.backgroundColor = [UIColor whiteColor];
                 viewforCopyLandscape2.alpha = 0.0f;

                 [self.navigationController.view addSubview:viewforCopyLandscape2];
                 [self.navigationController.view bringSubviewToFront:viewforCopyLandscape2];
                 [self.navigationController.view addSubview:viewForCopy];
                 [self.navigationController.view bringSubviewToFront:viewForCopy];

                 [newShadow removeFromSuperlayer];

                 [viewForCopy setFrame:CGRectMake([_gridView rectForItemAtIndex:index].origin.x, [_gridView rectForItemAtIndex:index].origin.y + 65, [_gridView rectForItemAtIndex:index].size.width, [_gridView rectForItemAtIndex:index].size.height)];

                 [[_gridView cellForItemAtIndex:index] setAlpha:0.0f];

                 self.view.userInteractionEnabled = NO;

                 [UIView animateWithDuration:1.5f
                                       delay:0.0f
                                     options:UIViewAnimationCurveEaseInOut
                                  animations:^{
                                      [viewforCopyLandscape2 setFrame:CGRectMake(0, 20, self.view.bounds.size.width/2, self.view.bounds.size.height)];
                                      [viewForCopy setFrame:CGRectMake(407, 10, self.view.bounds.size.width * .78, self.view.bounds.size.height * 1.25)];
                                      [self.navigationController.navigationBar setAlpha:0.0f];  
                                      viewforCopyLandscape2.alpha = 1.0f;
                                  } 
                                  completion:^(BOOL finished) {

                                      UIView *viewForCopyLandscape = [[[UIView alloc]initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height)]autorelease];
                                      UIGraphicsBeginImageContext(CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height));
                                      [self.navigationController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
                                      UIImageView *viewImage = [[[UIImageView alloc]initWithImage:UIGraphicsGetImageFromCurrentImageContext()]autorelease];
                                      UIGraphicsEndImageContext();
                                      viewForCopyLandscape = viewImage;
                                      [self.navigationController.view addSubview:viewForCopyLandscape];
                                      [self.navigationController.view bringSubviewToFront:viewForCopyLandscape];

                                      [viewForCopy setAlpha:0.0f];
                                      [UIView animateWithDuration:2.0f
                                                            delay:0.0f
                                                          options:UIViewAnimationCurveEaseInOut
                                                       animations:^{

                                                           CATransform3D transform = CATransform3DMakeRotation(-M_PI / 1.1, 0.0, 1.0, 0.0);
                                                           transform.m34 = 1.0f / 2500.0f;
                                                           viewForCopyLandscape.layer.transform = transform;

                                                           [self.navigationController.view sendSubviewToBack:viewForCopy];
                                                           [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:YES];
                                                           [self.navigationController pushViewController:viewController animated:NO];
                                                           [viewforCopyLandscape2 removeFromSuperview];

                                                       }           
                                                       completion:^(BOOL finished) {
                                                           [[_gridView cellForItemAtIndex:index] setAlpha:1.0f];
                                                           [viewForCopy removeFromSuperview];
                                                           [UIView animateWithDuration:1.00 animations:^ {
                                                               [viewForCopyLandscape setAlpha:0.0f];

                                                           }];
                                                       }];
                                  }];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文