-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLBorderShadowView.m
executable file
·46 lines (33 loc) · 1.24 KB
/
CLBorderShadowView.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
//
// CLBorderShadowView.m
// Cascade
//
// Created by Emil Wojtaszek on 23.08.2011.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import "CLBorderShadowView.h"
@implementation CLBorderShadowView
///////////////////////////////////////////////////////////////////////////////////////////////////
- (id)init {
self = [super init];
if (self) {
[self setBackgroundColor:[UIColor clearColor]];
}
return self;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void) drawRect:(CGRect)rect {
CGFloat colors [] = {
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.3
};
CGColorSpaceRef baseSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColorComponents(baseSpace, colors, NULL, 2);
CGColorSpaceRelease(baseSpace), baseSpace = NULL;
CGContextRef context = UIGraphicsGetCurrentContext();
CGPoint startPoint = CGPointMake(0, CGRectGetMidY(rect));
CGPoint endPoint = CGPointMake(CGRectGetMaxX(rect), CGRectGetMidY(rect));
CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0);
CGGradientRelease(gradient), gradient = NULL;
}
@end