Created
March 16, 2012 19:05
-
-
Save jivadevoe/2051886 to your computer and use it in GitHub Desktop.
Sample of PaintCode output.
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
| //// General Declarations | |
| CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | |
| CGContextRef context = UIGraphicsGetCurrentContext(); | |
| //// Gradient Declarations | |
| NSArray* gradientColors = [NSArray arrayWithObjects: | |
| (id)[UIColor blackColor].CGColor, | |
| (id)[UIColor whiteColor].CGColor, nil]; | |
| CGFloat gradientLocations[] = {0, 1}; | |
| CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)gradientColors, gradientLocations); | |
| //// Shadow Declarations | |
| CGColorRef shadow = [UIColor whiteColor].CGColor; | |
| CGSize shadowOffset = CGSizeMake(0, 1); | |
| CGFloat shadowBlurRadius = 1; | |
| //// Abstracted Graphic Attributes | |
| NSString* textContent = @"Delete"; | |
| //// Rounded Rectangle Drawing | |
| UIBezierPath* roundedRectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(67.5, 34.5, 76, 36) cornerRadius: 4]; | |
| CGContextSaveGState(context); | |
| [roundedRectanglePath addClip]; | |
| CGContextDrawLinearGradient(context, gradient, CGPointMake(105.5, 70.5), CGPointMake(105.5, 34.5), 0); | |
| CGContextRestoreGState(context); | |
| [[UIColor blackColor] setStroke]; | |
| roundedRectanglePath.lineWidth = 1; | |
| [roundedRectanglePath stroke]; | |
| //// Text Drawing | |
| CGContextSaveGState(context); | |
| CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow); | |
| CGRect textFrame = CGRectMake(68, 39, 75, 27); | |
| [[UIColor blackColor] setFill]; | |
| [textContent drawInRect: textFrame withFont: [UIFont fontWithName: @"Helvetica" size: 18] lineBreakMode: UILineBreakModeWordWrap alignment: UITextAlignmentCenter]; | |
| CGContextRestoreGState(context); | |
| //// Cleanup | |
| CGGradientRelease(gradient); | |
| CGColorSpaceRelease(colorSpace); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment