0

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

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,因为我还需要纵向滚动两页,以及横向和滚动同时放大两页。有没有办法做到这一点?现在它只是像一个巨大的横向页面一样卷曲整个视图。由于它使用两层,我怀疑有一种简单的方法可以做到这一点,但我想我会问。

4

2 回答 2

1

你不能在 UIScrollerView 中使用 UIPageViewController 吗?

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

唯一的问题是,除非您有 zoom = 1,否则您无法更改页面

于 2012-09-03T12:44:21.267 回答
0

还在想这个,如果你强制 UIPageViewController 以横向和纵向显示 2 个页面,并将其放在 UIScrollerView 中。当您处于横向时,它会显示 2 页、缩放并按预期工作。如果你是纵向的,你可以让 UIPageViewController frame.width 是单页的 double,并且 UIScrollerView contentSize 和 UIPageViewController 一样宽,但是 UIScrollerView 框架宽度和一个页面一样宽。这样做你只显示一个页面并且可以滚动到第二个页面。我已经测试过并且在横向上工作正常,但在纵向上有一些问题,滑动更改页面不能从内部工作,但这从外部工作(这就是为什么我设置 _zoomer.frame = CGRectMake(10,10,widht ,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;
}
}

_zoomer 是 UIScrollerView

于 2012-09-04T07:38:37.120 回答