From a9dffebf84b68d632785b2ba8ac4ac1fee6e0b75 Mon Sep 17 00:00:00 2001 From: Dave Verwer Date: Fri, 14 Dec 2012 18:48:31 +0000 Subject: [PATCH] Experimentation with transforms. --- ExploreCollectionViewTest/PhotoGridCollectionViewLayout.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ExploreCollectionViewTest/PhotoGridCollectionViewLayout.m b/ExploreCollectionViewTest/PhotoGridCollectionViewLayout.m index 7ff5e07..8047875 100644 --- a/ExploreCollectionViewTest/PhotoGridCollectionViewLayout.m +++ b/ExploreCollectionViewTest/PhotoGridCollectionViewLayout.m @@ -21,7 +21,7 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect // Change startPercentage to adjust when the cells start to transition out of their untransformed state // Values for start percentage are between 0 and 1 representing the range of 0 to half the screen - CGFloat const startPercentage = 0.4; + CGFloat const startPercentage = 0.75; // Pre-calculate as much as possible, values here will change when the bounds of the collection // view change but will not change for each cell @@ -51,7 +51,8 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect CGFloat angle = M_PI_2 * (1 - adjustedPercentageX); CATransform3D transform = CATransform3DIdentity; transform.m34 = 1.0 / -1000; // m34 must be set before the transform so it knows depth - transform = CATransform3DRotate(transform, angle * sideOfView, 0, 1, 0); + transform = CATransform3DRotate(transform, angle * sideOfView, 0, 1, 1); + transform = CATransform3DTranslate(transform, sideOfView * (100 * (1 - adjustedPercentageX)), 0, 0); attributes.transform3D = transform; // Set the anchor point for the cell depending on the side