views:

55

answers:

1

I have a pdf page displayed with CGContextDrawPDFPage.

I want to keep this page shown and have an image slide in from top over this page, just as it can be seen in the iBooks application.

It's a book, the sliding image is a bookmark that slides in when you are about to close the book.

What is the best way to go about implementing this?

A: 

Try using a UIView animation block that moves the frame of a UIImageView from above the top (offscreen) to somewhere below the top.

For example, assuming the image is 100 x 200:

[imageView setFrame:CGRectMake(150, -200, 100, 200)];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[imageView setFrame:CGRectMake(150, 0, 100, 200)];
[UIView commitAnimations];      

Just make sure that imageView is the top-most subview and not hidden.

DyingCactus
Thank you, this does the trick just fine. Should I make a new question or can you tell me how to implement your code so that it shows before the view displaying the pdf dissapears? I tried adding viewWillDisappear but it has no effect at all... Thank you!
BittenApple
When I place this in QuartzViewController.m, the animation starts to show but the view slides away. Is this the right direction to do it, for example by adding some sort of interruption like "wait with hiding the view until animation is over" or what? :)-(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]; }
BittenApple
I'll start a new question rather :)
BittenApple
I answered your new question.
DyingCactus
However, I'm wondering why you're animating self.quartzView instead of your bookmark image view. Isn't self.quartzView the pdf view?
DyingCactus
Thank you. I'm not, I will be animating a special image view which contains an image of the bookmark. Right now I'm trying to figure out how to do that :)
BittenApple