-
Notifications
You must be signed in to change notification settings - Fork 0
/
AxisView.m
49 lines (38 loc) · 1.52 KB
/
AxisView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// AxisView.m
// Metasome
//
// Created by Omar Metwally on 9/16/13.
// Copyright (c) 2013 Logisome. All rights reserved.
//
#import "AxisView.h"
@implementation AxisView
@synthesize ctx, transform;
-(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setCtx:UIGraphicsGetCurrentContext()];
[self setTransform:CGAffineTransformConcat(CGContextGetTextMatrix([self ctx]), CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0))];
}
return self;
}
-(void)drawRect:(CGRect)rect
{
[self setCtx:UIGraphicsGetCurrentContext()];
[self drawText:@"Test" fontSize:20.0 horizontalLocation:100 verticalLocation:100 rotation:0.0];
}
-(void)drawText:(NSString *)writeMe fontSize:(float)size horizontalLocation:(float)horizonal verticalLocation:(float)vertical rotation:(float)radians
{
[self setCtx:UIGraphicsGetCurrentContext()];
[self setTransform:CGAffineTransformRotate([self transform], radians)];
CGContextSetTextMatrix([self ctx], [self transform]);
CGContextSetRGBFillColor([self ctx], 0, 0, 0, 1);
CGContextSelectFont([self ctx], "Helvetica", size, kCGEncodingMacRoman);
CGContextSetCharacterSpacing([self ctx], 1.0);
CGContextSetTextDrawingMode([self ctx], kCGTextFill);
CGContextShowTextAtPoint([self ctx], horizonal, vertical + size, [writeMe UTF8String], [writeMe length]);
[self setTransform:CGAffineTransformRotate([self transform], -radians)];
CGContextSetTextMatrix([self ctx], [self transform]);
}
@end