Skip to content

Instantly share code, notes, and snippets.

@jivadevoe
Created March 16, 2012 19:05
Show Gist options
  • Select an option

  • Save jivadevoe/2051886 to your computer and use it in GitHub Desktop.

Select an option

Save jivadevoe/2051886 to your computer and use it in GitHub Desktop.
Sample of PaintCode output.
//// 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