-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPQCollectionViewCell.m
More file actions
77 lines (58 loc) · 1.58 KB
/
PQCollectionViewCell.m
File metadata and controls
77 lines (58 loc) · 1.58 KB
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
//
// PQCollectionViewCell.m
// PQCollectionViewCell
//
// Created by Paolo Arduin on 05/06/13.
// Copyright (c) 2013 Paolo Arduin. All rights reserved.
//
#import "PQCollectionViewCell.h"
@interface PQCollectionViewCellView : UIView
@end
@implementation PQCollectionViewCellView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.contentMode = UIViewContentModeRedraw;
self.opaque = YES;
}
return self;
}
- (void)drawRect:(CGRect)rect {
[(PQCollectionViewCell *)self.superview drawCellView:rect];
}
@end
@interface PQCollectionViewCell ()
@property (strong, readwrite) UIView *cellView;
@end
@implementation PQCollectionViewCell
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.cellView = [[PQCollectionViewCellView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
[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 removeFromSuperview];
[self.backgroundView removeFromSuperview];
[self bringSubviewToFront:self.selectedBackgroundView];
}
- (void)drawCellView:(CGRect)rect {
// subclasses should implement this
}
@end