Skip to content

Instantly share code, notes, and snippets.

@endash
Created April 9, 2012 16:45
Show Gist options
  • Save endash/2344654 to your computer and use it in GitHub Desktop.
Save endash/2344654 to your computer and use it in GitHub Desktop.
Page split
//// General Declarations
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = UIGraphicsGetCurrentContext();
//// Color Declarations
UIColor* leftHandColor2 = [UIColor colorWithRed: 0.32 green: 0.43 blue: 0.53 alpha: 0.03];
UIColor* leftHandColor1 = [UIColor colorWithRed: 0.32 green: 0.43 blue: 0.53 alpha: 0];
UIColor* rightHandColor1 = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 1];
UIColor* rightHandColor2 = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0];
//// Gradient Declarations
NSArray* leftHandSideOfPageSplitColors = [NSArray arrayWithObjects:
(id)leftHandColor1.CGColor,
(id)leftHandColor2.CGColor, nil];
CGFloat leftHandSideOfPageSplitLocations[] = {0, 1};
CGGradientRef leftHandSideOfPageSplit = CGGradientCreateWithColors(colorSpace, (CFArrayRef)leftHandSideOfPageSplitColors, leftHandSideOfPageSplitLocations);
NSArray* gradientColors = [NSArray arrayWithObjects:
(id)rightHandColor1.CGColor,
(id)rightHandColor2.CGColor, nil];
CGFloat gradientLocations[] = {0, 1};
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)gradientColors, gradientLocations);
//// PaintCode Trial Version
//// www.paintcodeapp.com
//// Rectangle Drawing
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRect: CGRectMake(0, 0, 5, 120)];
CGContextSaveGState(context);
[rectanglePath addClip];
CGContextDrawLinearGradient(context, leftHandSideOfPageSplit, CGPointMake(0, 60), CGPointMake(5, 60), 0);
CGContextRestoreGState(context);
//// Rectangle 2 Drawing
UIBezierPath* rectangle2Path = [UIBezierPath bezierPathWithRect: CGRectMake(4, 0, 1, 120)];
[leftHandColor2 setFill];
[rectangle2Path fill];
//// Rectangle 3 Drawing
UIBezierPath* rectangle3Path = [UIBezierPath bezierPathWithRect: CGRectMake(5, 0, 5, 120)];
CGContextSaveGState(context);
[rectangle3Path addClip];
CGContextDrawLinearGradient(context, gradient, CGPointMake(5, 60), CGPointMake(10, 60), 0);
CGContextRestoreGState(context);
//// Cleanup
CGGradientRelease(leftHandSideOfPageSplit);
CGGradientRelease(gradient);
CGColorSpaceRelease(colorSpace);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment