forked from b051/RSMenuView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VHRowBackgroundView.m
39 lines (31 loc) · 969 Bytes
/
VHRowBackgroundView.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
//
// VHRowBackgroundView.m
//
// Created by Rex Sheng on 10/16/12.
// Copyright (c) 2012 Log(n) LLC. All rights reserved.
//
#import "VHRowBackgroundView.h"
@implementation VHRowBackgroundView
@synthesize highlighted;
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
self.contentMode = UIViewContentModeRedraw;
self.backgroundColor = [UIColor clearColor];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGFloat lineHeight = .55f;
CGContextSetGrayFillColor(context, 0, 1);
CGContextFillRect(context, CGRectMake(0, rect.size.height - lineHeight, rect.size.width, lineHeight));
CGContextSetGrayFillColor(context, 1, highlighted ? .28f : .11f);
CGContextFillRect(context, CGRectMake(0, 0, rect.size.width, lineHeight));
if (highlighted) {
CGContextSetGrayFillColor(context, 1, .11f);
CGContextFillRect(context, CGRectInset(rect, 0, lineHeight));
}
}
@end