2011-12-25 2 views
1

(긴 게시물에 대한 나의 사과)을 갖는, 첨부 된 코드를 복사 UIView의에 선택한 셀이 다음 화면을 채우기 위해 확장하는 것을보기를 애니메이션, 다음 말했다 전체 화면 표지 애니메이션처럼 보이도록 변환합니다. 자유롭게 재사용 할 수는 있지만 내 문제는 아닙니다. 내 문제는 Landscape와 다른 애니메이션이어야합니다. 내 셀 뷰를 화면의 오른쪽 절반에 애니메이션으로 표시하고 화면의 오른쪽 절반을 채우도록 확장 한 다음 이미 화면에서 왼쪽으로 y 플립 회전을 수행합니다. CGPointMake에서 앵커 포인트 (0.5, 0.5); 작동하지 않으며 x 값을 화면의 반으로 설정하고 다시 x 값을 설정하지 않으면 그냥 수행 한 다음 화면에서 벗어납니다! 도움!!재즈까지 내 AQGridView 재미와 UIView의 애니메이션과 UIView의 뒤집기

편집 : (! 코드는 지금 제가의 self.navigationController.view 속성에 새로운 UIView's를 추가했다 실현하지 덕분에 노력하는 그래서했다 모두를 그 렌더링 플립했다, 어떤 번역이 필요하지 않습니다) 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]; 

                  }]; 
                 }]; 
            }]; 
} 

답변

0
지금 제가의 self.navigationController.view 속성에 새로운 UIView의의의를 추가했다 실현하지 덕분에 작동 코드는 그래서했다 모두를 그 렌더링 플립했다

은, 어떤 번역은 필요하지 !)

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]; 

                  }]; 
                 }]; 
            }]; 
}