2012-01-26 6 views
0

주보기 (self.view)에 UIButton이 연결되어 있습니다. 세로 모드에서 위치 (0, 0)에 앉아 있습니다.UIButton 전환 - 화면 전체에서 실행

사용자가 자신의 아이폰을 가로 모드로 전환하면 버튼이 화면 (200,0)을 가로 질러 위치하도록 표시됩니다.

내가 찾고있는 효과는보기를 변경하면 앞뒤로 부드럽게 움직이는 버튼입니다.

내 인생에서 애플 워드 프로세서 또는 Google 검색에서 이러한 전환을 찾을 수 없습니다. 내가 할 수있는 방법이 있니?

+0

되지는 않겠 애니메이션 블록 소송 목적을? – FiddleMeRagged

답변

1

보기 컨트롤러에서이 작업을 수행합니다 :

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromOrientation 

    UIInterfaceOrientation currentOrientation = self.interfaceOrientation; 
    CGRect buttonFrame = self.button.frame; 

    if (UIInterfaceOrientationIsPortrait(currentOrientation)) 
     buttonFrame.origin = CGPointMake(0, 0); 
    else 
     buttonFrame.origin = CGPointMake(200, 0); 

    [UIView animateWithDuration:1.0 animations:^ { 

     self.button.frame = buttonFrame; 
    }]; 
} 
+0

친절하게 감사드립니다. –

관련 문제