CATransition Page Curl With Spine in Middle



让页面卷曲动画工作起来很容易:

CATransition *transition = [CATransition animation];
[transition setDelegate:self];
[transition setDuration:0.5f];
[transition setType:@"pageCurl"];
[transition setSubtype:landscape ? @"fromBottom" : @"fromRight"];
[self.view.layer addAnimation:transition forKey:@"CurlAnim"];

然而,我的老板希望我在横向时从中间(就像在iBooks中一样)转向。我不能使用UIPageViewController,因为我还需要在纵向滚动两页,以及在横向和滚动中同时放大这两页。有办法做到这一点吗?现在它只是卷曲整个视图,就像一个巨大的横向页面。由于它使用了两层,我怀疑是否有简单的方法,但我想我应该问一下。

您不能在UIScrollerView中使用UIPageViewController吗?

这样,您可以放大/缩小两个页面。

唯一的问题是,除非缩放=1 ,否则无法更改页面

如果您强制UIPageViewController以横向和纵向显示两个页面,并将其放在UIScrollerView中,请继续考虑这一点。当您处于横向时,它会显示两个页面,缩放并按预期工作。如果您是纵向的,您可以使UIPageViewController框架.width为单页的两倍,而UIScrollerView内容大小与UIPageViewControl的宽度相同,但UIScroller View框架宽度与一页的宽度相同。这样做只会显示一页,并且可以滚动到第二页。我已经测试过并在横向上工作得很好,但在纵向上有一些问题,滑动来更改页面从内部不起作用,但这从外部起作用(这就是为什么我设置_zoomer.frame=CGCRectMake(10,10,widght,height),在UIPageViewController周围有一个10点的框架来从那里滑动),点击来更改页面也起作用。

我在屏幕旋转上使用的代码,并且仅适用于iPad。

 - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
CGRect pageViewRect;
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
    pageViewRect = CGRectMake(0,0,1496,984);
    _zoomer.contentSize=CGSizeMake(1496, 984);
    _zoomer.frame = CGRectMake(10,10,748,984);
    self.pageViewController.view.frame = pageViewRect;
} else {
    pageViewRect = CGRectMake(0,0,1004,728);
    _zoomer.frame = CGRectMake(10,10,1004,728);
    _zoomer.contentSize=CGSizeMake(1004, 728);
    self.pageViewController.view.frame = pageViewRect;
}
}

_缩放器是UIScrollerView

最新更新