0

我正在使用Leaves 项目从一个 pdf 页面移动到另一个它工作正常。现在页面卷曲是从左到右,从右到左,就像一个笔记本。我需要从上到下和从下到上卷曲它。有谁知道这样做的方法,或任何其他模板来做到这一点?

4

3 回答 3

4

只需使用 Apple 的 UIPageViewController 而不是 Leaves http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIPageViewControllerClassReferenceClassRef/UIPageViewControllerClassReference.html

例如,这为您提供了他们在 iBooks 中使用的准确卷曲,因此卷曲视图的矩阵更漂亮(更逼真)。

只需将所有笔记设为 View 并为视图提供 UIPageViewController 它还有脊椎所在的各种选项以及其他内容

要进行卷曲,您可以 [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];像提到的 bala 那样使用或实例化另一个负责向上和向下转换的 UIPageViewController。如果您想真正进入视图并可能通过多个项目进行切换,我将只使用 2 个 uipageviewcontrollers 所以一个水平和一个垂直

于 2012-08-22T13:46:59.797 回答
2

这种方法

 SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
    [sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
    [self presentModalViewController:sampleView animated:YES]; 

教程中可能会有所帮助

于 2012-08-22T05:29:41.597 回答
1

现有的叶子视图被硬编码为从左到右。您可以轻松地创建一个硬编码的自上而下的版本,但很可能有更强大的通用解决方案。

但是,如果你一定要使用叶子,你可以重写它的源代码以适应它。下面的解决方案硬编码垂直运动。如果您需要水平和垂直选项,您将需要做更多的工作。


展示

设置图层

在每次调用中反转轴CGPointMake。这修复了显示阴影的渐变。

也更改topPage.contentsGravity = kCAGravityLeft;topPage.contentsGravity = kCAGravityBottom;topPageReverseImage.contentsGravity = kCAGravityRight;topPageReverseImage.contentsGravity = kCAGravityTop;这是一个微妙的变化,可确保传入的页面以正确的边缘显示。

setLayerFrames

大多数几何变化都发生在这里。原始代码奇怪地在某些地方使用了视图边界,而在其他地方使用了图层边界。我复制了这些,但最好在生产中使用此代码之前了解区别是否有意义。

- (void) setLayerFrames {
    topPage.frame = CGRectMake(self.layer.bounds.origin.x, 
                               self.layer.bounds.origin.y, 
                               self.bounds.size.width,
                               leafEdge * self.layer.bounds.size.height);
    topPageReverse.frame = CGRectMake(self.layer.bounds.origin.x,
                                      self.layer.bounds.origin.y + (2*leafEdge-1) * self.layer.bounds.size.height,
                                      self.bounds.size.width,
                                      (1-leafEdge) * self.layer.bounds.size.height);
    bottomPage.frame = self.layer.bounds;
    topPageShadow.frame = CGRectMake(0,
                                     topPageReverse.frame.origin.y - 40,
                                     bottomPage.bounds.size.width,
                                     40);
    topPageReverseImage.frame = topPageReverse.bounds;
    topPageReverseImage.transform = CATransform3DMakeScale(1, -1, 1);
    topPageReverseOverlay.frame = topPageReverse.bounds;
    topPageReverseShading.frame = CGRectMake(0,
                                             topPageReverse.bounds.size.height - 50,
                                             topPageReverse.bounds.size.width,
                                             50 + 1);
    bottomPageShadow.frame = CGRectMake(0,
                                        leafEdge * self.bounds.size.height,
                                        bottomPage.bounds.size.width,
                                        40);
    topPageOverlay.frame = topPage.bounds;
}

相互作用

更新目标矩形

在哪里计算nextPageRectprevPageRect,将它们放在底部和顶部而不是左右。

touchesMoved:withEvent:

更改self.leafEdge = touchPoint.x / self.bounds.size.width;self.leafEdge = touchPoint.y / self.bounds.size.height;

于 2012-08-28T01:06:38.960 回答