CGContextDrawPDFPage 上的图像动画
我在 QuartzDemo 示例应用程序中使用 CGContextDrawPDFPage 显示了一个 pdf 页面。
我想保持此页面显示,并从该页面顶部滑入图像,就像在 iBooks 应用程序中看到的那样。
这是一本书,滑动图像是一个书签,当你要合上书时,它会滑进去。
我通过 DyingCactus 添加了这段代码(提示:我是 obj c 和 iphone dev 的新手),如下所示:
在 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];
}
如何保持视图可见并在视图消失之前完成动画?
I have a pdf page displayed with CGContextDrawPDFPage in QuartzDemo sample application.
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.
I added this code by DyingCactus (hint: im a newbie to obj c and iphone dev) as follows:
In QuartzViewController.m, the animation starts to show but the view slides away before the animation is finished, in fact I think the animation goes on while the view is sliding away.
-(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];
}
How can I keep the view visible and finish the animation before view disappears?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您正在修改 Apple 的 QuartzDemo 示例应用程序。
我现在能想到的最好方法是,当显示的视图是 PDF 视图时,用您自己的按钮替换导航控制器上的后退按钮。
然后,您的自定义后退按钮可以根据需要管理动画并查看弹出序列。
唯一令人烦恼的是后退按钮不再具有左箭头形状。
以下是 QuartzViewController.m 中所需的更改:
I assume you're modifying the QuartzDemo sample app from Apple.
Best way I can think of right now is to replace the back button on the navigation controller with your own button when the view being shown is the PDF view.
Your custom back button can then manage the animation and view popping sequence as needed.
Only annoyance with this is that the back button no longer has a left-arrow shape.
Here are the changes needed in QuartzViewController.m: