Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The existing leaves view is hard-coded to be left-to-right. You can create a hard-coded top-to-bottom version easily enough, but there may well be more robust generic solutions.</p> <p>However, if you definitely must use leaves, you can rewrite its source to suit. The solution below hard-codes for vertical motion. If you need horizontal and vertical options, you will have more work do do.</p> <hr> <h1>Display</h1> <h2>setUpLayers</h2> <p>Reverse the axes in every call to <code>CGPointMake</code>. This fixes up the gradients that display the shadows.</p> <p>Also change <code>topPage.contentsGravity = kCAGravityLeft;</code> to <code>topPage.contentsGravity = kCAGravityBottom;</code> and <code>topPageReverseImage.contentsGravity = kCAGravityRight;</code> to <code>topPageReverseImage.contentsGravity = kCAGravityTop;</code>. This is a subtle change that makes sure incoming pages are displayed with the correct edges.</p> <h2>setLayerFrames</h2> <p>Most of the geometry changes happen here. The original code oddly uses view bounds in some places and layer bounds in others. I duplicated those, but it would be good to understand if the distinction is meaningful before using this code in production. </p> <pre><code>- (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; } </code></pre> <hr> <h1>Interaction</h1> <h2>updateTargetRects</h2> <p>Where this calculates <code>nextPageRect</code> and <code>prevPageRect</code>, put them on the bottom and top instead of the right and left.</p> <h2>touchesMoved:withEvent:</h2> <p>Change <code>self.leafEdge = touchPoint.x / self.bounds.size.width;</code> to <code>self.leafEdge = touchPoint.y / self.bounds.size.height;</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload