-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathEUMTouchPointView.m
64 lines (49 loc) · 1.59 KB
/
EUMTouchPointView.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
56
57
58
59
60
61
62
63
64
//
// EUMTouchPointView.m
//
// Created by Shawn on 12/8/14.
// Copyright (c) 2014 EUMLab. All rights reserved.
//
#import "EUMTouchPointView.h"
@implementation EUMTouchPointView
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.opaque = NO;
}
return self;
}
-(void)drawRect:(CGRect)rect{
CGRect frm = self.frame;
[self drawPointer:frm.size stockWidth:3];
}
- (void)drawPointer: (CGSize)pointSize stockWidth: (CGFloat)stockWidth
{
//// General Declarations
CGContextRef context = UIGraphicsGetCurrentContext();
//// Color Declarations
UIColor* color = [UIColor colorWithRed: 0 green: 0.734 blue: 1 alpha: 0.694];
if (self.pointerColor) {
color = self.pointerColor;
}
//// Shadow Declarations
UIColor* shadow = [UIColor.blackColor colorWithAlphaComponent: 0.2];
CGSize shadowOffset = CGSizeMake(0.1, -0.1);
CGFloat shadowBlurRadius = 4;
//// Oval Drawing
UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(5, 5, pointSize.width - 10, pointSize.height -10)];
[color setFill];
[ovalPath fill];
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, [shadow CGColor]);
if (self.pointerStockColor) {
[self.pointerStockColor setStroke];
}else{
[UIColor.whiteColor setStroke];
}
ovalPath.lineWidth = stockWidth;
[ovalPath stroke];
CGContextRestoreGState(context);
}
@end