Created
February 22, 2013 01:22
-
-
Save Arthraim/5010034 to your computer and use it in GitHub Desktop.
A practice of quartz. Draw something like table -///-
This file contains 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
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetRGBStrokeColor (context, 0, 0, 0, 1); | |
CGContextSetLineWidth(context, 1); | |
CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0)); | |
int hours = 0; | |
float gap = self.height / 24; | |
for (float y = gap; y < self.height + gap / 2; y += gap) { | |
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), 0, y); | |
CGContextAddLineToPoint(context, self.width, y); | |
CGContextSelectFont(context, | |
"Helvetica-Bold", | |
gap, | |
kCGEncodingMacRoman); | |
CGContextSetCharacterSpacing(context, 0); | |
CGContextSetTextDrawingMode(context, kCGTextFill); | |
CGContextSetRGBStrokeColor(context, 0, 0, 0, 1); | |
const char *str = [[NSString stringWithFormat:@"%02d", hours] cStringUsingEncoding:NSUTF8StringEncoding]; | |
CGContextShowTextAtPoint(context, 3, y, str, strlen(str)); | |
hours++; | |
} | |
CGContextDrawPath(context, kCGPathStroke); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment