首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用叶子视图进行页面渲染

使用叶子视图进行页面渲染
EN

Stack Overflow用户
提问于 2012-07-17 11:52:51
回答 3查看 569关注 0票数 0

我正在使用Leaves project从一个pdf页面移动到另一个,它工作得很好。现在,页面卷曲是从左到右,从右到左,就像笔记本一样。我需要从上到下,从下到上卷曲它。有没有人知道做这件事的方法,或者其他的模板?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-08-28 09:06:39

现有的leaves视图被硬编码为从左到右。您可以很容易地创建一个硬编码的自上而下的版本,但很可能有更健壮的通用解决方案。

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

显示

setUpLayers

在每个对CGPointMake的调用中反转坐标轴。这会修复显示阴影的渐变。

还要将topPage.contentsGravity = kCAGravityLeft;更改为topPage.contentsGravity = kCAGravityBottom;,将topPageReverseImage.contentsGravity = kCAGravityRight;更改为topPageReverseImage.contentsGravity = kCAGravityTop;。这是一个细微的变化,它确保传入的页面以正确的边缘显示。

setLayerFrames

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

代码语言:javascript
复制
- (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;
}

互动

updateTargetRects

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

touchesMoved:withEvent:

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

票数 1
EN

Stack Overflow用户

发布于 2012-08-22 21:47:00

用苹果的UIPageViewController代替Leave http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIPageViewControllerClassReferenceClassRef/UIPageViewControllerClassReference.html就行了

例如,这给出了他们在iBooks中使用的卷曲,因此卷曲视图的矩阵更漂亮(更逼真)。

只需将所有笔记页创建为一个视图,并为视图提供UIPageViewController,它还具有各种选项,包括脊椎所在位置和其他内容

要做一个卷曲,你可以像上面提到的那样使用[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];,或者实例化另一个负责向上和向下转换的UIPageViewController。如果你真的想进入视图,也许可以在多个项目之间切换,我只需要使用2个use控制器,一个水平,一个垂直。

票数 4
EN

Stack Overflow用户

发布于 2012-08-22 13:29:42

此方法

代码语言:javascript
复制
 SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
    [sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
    [self presentModalViewController:sampleView animated:YES]; 

就像在this中一样,教程可能会有所帮助

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11515799

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档