Permalink
Browse files

Antialias edges

  • Loading branch information...
peyton committed Feb 29, 2012
1 parent e5319bd commit dafb059d4464c52219b748a3942b63baa1127c58
@@ -41,7 +41,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
- <key>UIViewEdgeAntialiasing</key>
- <true/>
</dict>
</plist>
@@ -36,6 +36,9 @@ - (id)init;
// UITableViewCell has, by default, a transparent background. Set to white.
self.cell.backgroundColor = [UIColor whiteColor];
+ self.layer.rasterizationScale = [UIScreen mainScreen].scale;
+ self.layer.shouldRasterize = YES;
+
return self;
}
@@ -47,10 +50,16 @@ - (id)initWithCell:(UITableViewCell *)cell;
// Configure view
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.backgroundColor = [UIColor blackColor];
+ self.clipsToBounds = YES;
// Create transform layer
self.rotationView = [[UIView alloc] initWithFrame:CGRectZero];
- self.rotationView.layer.anchorPoint = CGPointMake(0.5f, 1.0f);
+
+ // Allow antialiasing
+ self.rotationView.layer.borderColor = self.backgroundColor.CGColor;
+ self.rotationView.layer.borderWidth = 3.0f;
+ self.rotationView.layer.rasterizationScale = [UIScreen mainScreen].scale;
+ self.rotationView.layer.shouldRasterize = YES;
// Configure cell
self.cell = cell;
@@ -78,6 +87,12 @@ - (id)initWithFrame:(CGRect)frame;
- (void)dealloc;
{
self.delegate = nil;
+ self.cell = nil;
+ self.configurationBlock = nil;
+ self.gradientView = nil;
+ self.rotationView = nil;
+
+ AH_SUPER_DEALLOC;
}
#pragma mark - Subview methods
@@ -87,7 +102,17 @@ - (void)layoutSubviews;
// Expand cell, gradientView, and rotationView to fit createView
self.cell.layer.bounds = self.bounds;
self.gradientView.layer.bounds = self.bounds;
- self.rotationView.layer.bounds = self.bounds;
+ self.rotationView.layer.bounds = CGRectInset(self.bounds, -self.rotationView.layer.borderWidth, -self.rotationView.layer.borderWidth);
+
+ // Set rotation view anchorPoint to the max Y, accounting for border width
+ self.rotationView.layer.anchorPoint = CGPointMake(0.5f, 1.0f - self.rotationView.layer.borderWidth / CGRectGetHeight(self.rotationView.layer.bounds));
+
+ // Position cell in the center of rotation view
+ CGPoint rotationCenter = CGPointMake(CGRectGetMidX(self.rotationView.layer.bounds), CGRectGetMidY(self.rotationView.layer.bounds));
+ self.cell.layer.position = rotationCenter;
+
+ // Position gradientView in the top left
+ self.gradientView.layer.position = CGPointZero;
}
- (CGSize)sizeThatFits:(CGSize)size;
@@ -145,7 +170,7 @@ - (void)handleContentOffsetChangedNotification:(NSNotification *)notification;
CGPoint contentOffet = [[notification.userInfo objectForKey:MOOKeyContentOffset] CGPointValue];
// Calculate transition progress
- CGFloat progress = MIN(-contentOffet.y / CGRectGetHeight(self.rotationView.bounds), 1.0f);
+ CGFloat progress = MIN(-contentOffet.y / CGRectGetHeight(self.bounds), 1.0f);
//
CGFloat angle = acosf(progress);
@@ -165,7 +190,7 @@ - (void)handleContentOffsetChangedNotification:(NSNotification *)notification;
if (((UITableView *)self.superview).separatorStyle == UITableViewCellSeparatorStyleSingleLine)
positionY -= 1.0f - progress;
- self.rotationView.layer.position = CGPointMake(CGRectGetWidth(self.layer.bounds) / 2.0f, positionY);
+ self.rotationView.layer.position = CGPointMake(CGRectGetMidX(self.layer.bounds), positionY);
// Set opacity to mimic shadows
self.gradientView.layer.opacity = MAX(1.0f - progress, 0.0f);
@@ -41,6 +41,8 @@ - (void)dealloc;
// Clean up memory
self.triggerView = nil;
+
+ AH_SUPER_DEALLOC;
}
#pragma mark - MOOPullGestureRecognizer methods
@@ -90,6 +90,8 @@ - (void)dealloc;
self.loadingText = nil;
self.pullToRefreshText = nil;
self.releaseText = nil;
+
+ AH_SUPER_DEALLOC;
}
#pragma mark - Subview methods

0 comments on commit dafb059

Please sign in to comment.