2010-05-30 5 views
0

QuartzDemo 샘플 응용 프로그램에서 CGContextDrawPDFPage와 함께 pdf 페이지가 표시됩니다.CGContextDrawPDFPage 이상의 이미지 애니메이션

iBooks 응용 프로그램에서 볼 수있는 것처럼이 페이지를 계속 유지하고 이미지를이 페이지의 맨 위에서 슬라이드하고 싶습니다.

책입니다. 슬라이딩 이미지는 책을 닫으려고 할 때 슬라이드하는 북마크입니다.

DyingCactus하여이 코드를 추가 (힌트 : C 및 아이폰 데브 obj와 초보자 임)

가 QuartzViewController.m에서 애니메이션이 시작

를 게재하지만보기 애니메이션 전에 멀리 미끄러 다음을 실제로는 애니메이션이 계속 움직이는 것처럼 보입니다.

-(void)viewWillDisappear:(BOOL)animated 
{ 
    [self.quartzView setFrame:CGRectMake(150, -200, 100, 200)]; 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    [self.quartzView setFrame:CGRectMake(150, 0, 100, 200)]; 
    [UIView commitAnimations]; 
} 

보기가 사라지지 않게하려면보기를 계속 표시하고 애니메이션을 끝내려면 어떻게해야합니까?

답변

0

Apple에서 QuartzDemo 샘플 앱을 수정한다고 가정합니다. 뷰는 PDF보기입니다 표시되는 경우 지금 내가 생각할 수있는

가장 좋은 방법은 자신의 버튼으로 네비게이션 컨트롤러의 뒤로 가기 버튼을 대체하는 것입니다.

사용자 정의 뒤로 단추는 필요에 따라 애니메이션을 관리하고 팝업 시퀀스를 볼 수 있습니다.

다시 말해서 뒤로 버튼에는 왼쪽 화살표 모양이 없습니다.

#import "QuartzImages.h" //<-- add this import 
... 
-(void)viewDidLoad 
{ 
    // Add the QuartzView 
    [scrollView addSubview:self.quartzView]; 

    //add custom back button if this is the PDF view... 
    if ([self.quartzView isKindOfClass:[QuartzPDFView class]]) 
    { 
     self.navigationItem.leftBarButtonItem = 
     [[UIBarButtonItem alloc] initWithTitle:@"QuartzDemo" 
           style:UIBarButtonItemStyleBordered 
           target:self 
           action:@selector(myBackButtonHandler:)]; 
    } 
} 

- (void)myBackButtonHandler:(id)sender 
{ 
    [self.quartzView setFrame:CGRectMake(150, -200, 100, 200)]; 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 
    [UIView setAnimationDuration:1.0]; 
    [self.quartzView setFrame:CGRectMake(150, 0, 100, 200)]; 
    [UIView commitAnimations]; 
} 

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 
{ 
    [self.navigationController popViewControllerAnimated:YES]; 
} 
: 여기

는 QuartzViewController.m에 필요한 변화입니다