-
Notifications
You must be signed in to change notification settings - Fork 1
/
TableCellSelectedView.m
61 lines (53 loc) · 1.12 KB
/
TableCellSelectedView.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
//
// TableCellSelectedView.m
//
// Copyright (c) 2013 Symbiotic Software LLC. All rights reserved.
//
#import "TableCellSelectedView.h"
#import "UIColorAddition.h"
@interface TableCellSelectedView ()
{
@private
UIColor *color;
UIColor *highColor;
CAGradientLayer *gradientLayer;
}
@end
@implementation TableCellSelectedView
- (id)initWithFrame:(CGRect)frame withColor:(UIColor *)aColor
{
if (self = [super initWithFrame:frame])
{
color = [aColor retain];
highColor = [[color colorLightenedBy:0.5] retain];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
if(IS_IOS_GTE(@"7.0"))
{
CGContextRef context = UIGraphicsGetCurrentContext();
[color setFill];
CGContextFillRect(context, rect);
}
else
{
if(!gradientLayer)
{
gradientLayer = [[CAGradientLayer alloc] init];
gradientLayer.frame = self.frame;
[gradientLayer setColors:[NSArray arrayWithObjects:(id)[highColor CGColor], (id)[color CGColor], nil]];
[self.layer insertSublayer:gradientLayer atIndex:0];
}
}
[super drawRect:rect];
}
- (void)dealloc
{
[color release];
[highColor release];
[gradientLayer release];
[super dealloc];
}
@end