-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphView.m
54 lines (39 loc) · 1.23 KB
/
graphView.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
50
51
52
53
54
//
// graphView.m
// CurrencyCalculator
//
// Created by Eric Martin on 7/1/14.
// Copyright (c) 2014 Martin Developments. All rights reserved.
//
#import "graphView.h"
@implementation graphView
@synthesize percentOff;
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
int radius = (rect.size.width-5)/2;
int centerX = radius;
int centerY = radius;
UIBezierPath* circlePath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(rect.origin.x,rect.origin.y,rect.size.width-5,rect.size.height-5)];
[[UIColor orangeColor] setFill];
[circlePath fill];
//Arc
double arcRadians = (2*M_PI)*percentOff;
NSLog(@"%g",arcRadians);
CGContextSetRGBFillColor(context, 0.5, 0.0, 0.5, 1.0);
CGContextAddArc(context, centerX, centerY, radius, M_PI_2*3, M_PI_2*3+arcRadians, NO);
CGContextAddLineToPoint(context, centerX, centerY);
CGContextAddLineToPoint(context, centerX, 0);
CGContextClosePath(context);
CGContextFillPath(context);
// CGContextStrokePath(context);
}
@end