#import "ZCMCommon.h"
#import <UIKit/UIKit.h>
Go to the source code of this file.
|
void | drawLinearGradient (CGContextRef context, CGRect rect, CGColorRef startColor, CGColorRef endColor) |
|
CGRect | rectFor1PxStroke (CGRect rect) |
|
void | draw1PxStroke (CGContextRef context, CGPoint startPoint, CGPoint endPoint, CGColorRef color) |
|
void | drawGlossAndGradient (CGContextRef context, CGRect rect, CGColorRef startColor, CGColorRef endColor) |
|
CGMutablePathRef | createArcPathFromBottomOfRect (CGRect rect, CGFloat arcHeight) |
|
◆ createArcPathFromBottomOfRect()
CGMutablePathRef createArcPathFromBottomOfRect |
( |
CGRect |
rect, |
|
|
CGFloat |
arcHeight |
|
) |
| |
Definition at line 64 of file ZCMCommon.m.
66 CGRect arcRect = CGRectMake(rect.origin.x, rect.origin.y + rect.size.height - arcHeight, rect.size.width, arcHeight);
68 CGFloat arcRadius = (arcRect.size.height/2) + (pow(arcRect.size.width, 2) / (8*arcRect.size.height));
69 CGPoint arcCenter = CGPointMake(arcRect.origin.x + arcRect.size.width/2, arcRect.origin.y + arcRadius);
71 CGFloat angle = acos(arcRect.size.width / (2*arcRadius));
72 CGFloat startAngle =
radians(180) + angle;
73 CGFloat endAngle =
radians(360) - angle;
75 CGMutablePathRef path = CGPathCreateMutable();
76 CGPathAddArc(path, NULL, arcCenter.x, arcCenter.y, arcRadius, startAngle, endAngle, 0);
77 CGPathAddLineToPoint(path, NULL, CGRectGetMaxX(rect), CGRectGetMinY(rect));
78 CGPathAddLineToPoint(path, NULL, CGRectGetMinX(rect), CGRectGetMinY(rect));
79 CGPathAddLineToPoint(path, NULL, CGRectGetMinX(rect), CGRectGetMaxY(rect));
static double radians(double degrees)
◆ draw1PxStroke()
void draw1PxStroke |
( |
CGContextRef |
context, |
|
|
CGPoint |
startPoint, |
|
|
CGPoint |
endPoint, |
|
|
CGColorRef |
color |
|
) |
| |
Definition at line 40 of file ZCMCommon.m.
42 CGContextSaveGState(context);
43 CGContextSetLineCap(context, kCGLineCapSquare);
44 CGContextSetStrokeColorWithColor(context, color);
45 CGContextSetLineWidth(context, 1.0);
46 CGContextMoveToPoint(context, startPoint.x + 0.5, startPoint.y + 0.5);
47 CGContextAddLineToPoint(context, endPoint.x + 0.5, endPoint.y + 0.5);
48 CGContextStrokePath(context);
49 CGContextRestoreGState(context);
◆ drawGlossAndGradient()
void drawGlossAndGradient |
( |
CGContextRef |
context, |
|
|
CGRect |
rect, |
|
|
CGColorRef |
startColor, |
|
|
CGColorRef |
endColor |
|
) |
| |
Definition at line 52 of file ZCMCommon.m.
56 UIColor * glossColor1 = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.35];
57 UIColor * glossColor2 = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.1];
59 CGRect topHalf = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height/2);
void drawLinearGradient(CGContextRef context, CGRect rect, CGColorRef startColor, CGColorRef endColor)
◆ drawLinearGradient()
void drawLinearGradient |
( |
CGContextRef |
context, |
|
|
CGRect |
rect, |
|
|
CGColorRef |
startColor, |
|
|
CGColorRef |
endColor |
|
) |
| |
Definition at line 12 of file ZCMCommon.m.
14 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
15 CGFloat locations[] = { 0.0, 1.0 };
17 NSArray *colors = @[(__bridge id) startColor, (__bridge id) endColor];
19 CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef) colors, locations);
21 CGPoint startPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect));
22 CGPoint endPoint = CGPointMake(CGRectGetMidX(rect), CGRectGetMaxY(rect));
24 CGContextSaveGState(context);
25 CGContextAddRect(context, rect);
26 CGContextClip(context);
27 CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0);
28 CGContextRestoreGState(context);
30 CGGradientRelease(gradient);
31 CGColorSpaceRelease(colorSpace);
◆ rectFor1PxStroke()
CGRect rectFor1PxStroke |
( |
CGRect |
rect | ) |
|
Definition at line 35 of file ZCMCommon.m.
37 return CGRectMake(rect.origin.x + 0.5, rect.origin.y + 0.5, rect.size.width - 1, rect.size.height - 1);