Created
July 10, 2012 04:10
-
-
Save jeswang-gist/3080946 to your computer and use it in GitHub Desktop.
Obj-C: stimulate the highlightBule
This file contains hidden or 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
| + (UIImage *) imageForSelectedBlue { | |
| CGRect rect = CGRectMake(0, 0, 10, 10); | |
| UIGraphicsBeginImageContext(rect.size); | |
| CGContextRef context = UIGraphicsGetCurrentContext(); | |
| size_t num_locations = 2; | |
| CGFloat locations[2] = { 0.0, 1.0 }; | |
| CGFloat components[8] = { 0.021, 0.548, 0.962, 1.000, 0.008, 0.364, 0.900, 1.000 }; | |
| CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB(); | |
| CGGradientRef selectionGradient = CGGradientCreateWithColorComponents(rgbColorspace, components, locations, num_locations); | |
| CGPoint startPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect)); | |
| CGPoint endPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMaxY(rect)); | |
| CGContextDrawLinearGradient(context, selectionGradient, startPoint, endPoint, 0); | |
| CGGradientRelease(selectionGradient); | |
| CGColorSpaceRelease(rgbColorspace); | |
| UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); | |
| UIGraphicsEndImageContext(); | |
| return img; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment