This repository has been archived by the owner on Feb 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSPLockOverlay.m
executable file
·55 lines (44 loc) · 1.59 KB
/
SPLockOverlay.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
55
//
// SPLockOverlay.m
// SuQian
//
// Created by Suraj on 25/9/12.
// Copyright (c) 2012 Suraj. All rights reserved.
//
#import "SPLockOverlay.h"
#define kLineColor [UIColor colorWithRed:170./255.0 green:170.0/255.0 blue:170.0/255.0 alpha:0.8]
#define kLineGridColor [UIColor colorWithRed:255./255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.]
@implementation SPLockOverlay
@synthesize pointsToDraw;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.backgroundColor = [UIColor clearColor];
self.pointsToDraw = [[NSMutableArray alloc]init];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGFloat lineWidth = 1.0;
CGContextSetLineWidth(context, lineWidth);
CGContextSetStrokeColorWithColor(context, kLineColor.CGColor);
for(SPLine *line in self.pointsToDraw)
{
CGContextMoveToPoint(context, line.fromPoint.x, line.fromPoint.y);
CGContextAddLineToPoint(context, line.toPoint.x, line.toPoint.y);
CGContextStrokePath(context);
CGFloat nodeRadius = 14.0;
CGRect fromBubbleFrame = CGRectMake(line.fromPoint.x- nodeRadius/2, line.fromPoint.y - nodeRadius/2, nodeRadius, nodeRadius);
CGContextSetFillColorWithColor(context, kLineGridColor.CGColor);
CGContextFillEllipseInRect(context, fromBubbleFrame);
if(line.isFullLength){
CGRect toBubbleFrame = CGRectMake(line.toPoint.x - nodeRadius/2, line.toPoint.y - nodeRadius/2, nodeRadius, nodeRadius);
CGContextFillEllipseInRect(context, toBubbleFrame);
}
}
}
@end