Created
July 27, 2012 23:46
-
-
Save christianroman/3191095 to your computer and use it in GitHub Desktop.
UITableViewCell gradient using Quartz 2D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGContextRef currentContext = UIGraphicsGetCurrentContext(); | |
CGGradientRef glossGradient; | |
CGColorSpaceRef rgbColorspace; | |
size_t num_locations = 2; | |
CGFloat locations[2] = { 0.0, 1.0 }; | |
CGFloat components[8] = { 1.0, 1.0, 1.0, 1, | |
0.95, 0.95, 0.95, 1 }; | |
rgbColorspace = CGColorSpaceCreateDeviceRGB(); | |
glossGradient = CGGradientCreateWithColorComponents(rgbColorspace, components, locations, num_locations); | |
CGRect currentBounds = self.bounds; | |
CGPoint topCenter = CGPointMake(CGRectGetMidX(currentBounds), 0.0f); | |
CGPoint midCenter = CGPointMake(CGRectGetMidX(currentBounds), CGRectGetMaxY(currentBounds)); | |
CGContextDrawLinearGradient(currentContext, glossGradient, topCenter, midCenter, 0); | |
CGGradientRelease(glossGradient); | |
CGColorSpaceRelease(rgbColorspace); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment