-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPQTableViewCell.m
86 lines (67 loc) · 1.96 KB
/
PQTableViewCell.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// PQTableViewCell.m
// PQTableViewCell
//
// Created by Paolo Arduin on 05/15/13.
// Copyright (c) 2013 Paolo Arduin. All rights reserved.
//
// Based on ABTableViewCell by Loren Brichter.
//
#import "PQTableViewCell.h"
@interface PQTableViewCellView : UIView
@end
@implementation PQTableViewCellView
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
self.contentMode = UIViewContentModeRedraw;
self.opaque = YES;
}
return self;
}
- (void)drawRect:(CGRect)rect {
[(PQTableViewCell *)self.superview drawCellView:rect];
}
@end
@interface PQTableViewCell ()
@property (strong, readwrite) UIView *cellView;
@end
@implementation PQTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.cellView = [[PQTableViewCellView alloc] initWithFrame:CGRectZero];
[self addSubview:self.cellView];
}
return self;
}
- (void)setFrame:(CGRect)frame {
[super setFrame:frame];
self.cellView.frame = self.bounds;
[self setNeedsDisplay];
}
- (void)setNeedsDisplay {
[super setNeedsDisplay];
[self.cellView setNeedsDisplay];
}
- (void)setNeedsDisplayInRect:(CGRect)rect {
[super setNeedsDisplayInRect:rect];
[self.cellView setNeedsDisplayInRect:rect];
}
- (void)layoutSubviews {
[super layoutSubviews];
self.contentView.hidden = YES;
[self.contentView removeFromSuperview];
self.textLabel.hidden = YES;
[self.textLabel removeFromSuperview];
self.detailTextLabel.hidden = YES;
[self.detailTextLabel removeFromSuperview];
self.backgroundView.hidden = YES;
[self.backgroundView removeFromSuperview];
self.selectedBackgroundView.hidden = YES;
[self.selectedBackgroundView removeFromSuperview];
self.imageView.hidden = YES;
[self.imageView removeFromSuperview];
}
- (void)drawCellView:(CGRect)rect {
// subclasses should implement this
}
@end