Skip to content

Commit 013dde2

Browse files
committed
Avoid background reset from UITableViewCell
1 parent 3a1ffb2 commit 013dde2

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

BitStore/Cells/TransactionCell.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,10 @@ - (void)updateValues {
101101
}
102102
}
103103

104+
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
105+
// hack to avoid the background reset the UITableView does on all subviews
106+
[super setHighlighted:highlighted animated:animated];
107+
[_circleIndicator setHighlighted:highlighted animated:animated];
108+
}
109+
104110
@end

BitStore/Views/CircleIndicator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
- (id)initWithCircles:(int)numberOfCircles;
1414
- (void)setFilledCircles:(int)filledCircles;
15+
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated;
1516

1617
- (id)init UNAVAILABLE_ATTRIBUTE;
1718
- (instancetype)initWithFrame:(CGRect)frame UNAVAILABLE_ATTRIBUTE;

BitStore/Views/CircleIndicator.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@implementation CircleIndicator {
1414
NSMutableArray* _circleViews;
15+
int _filledCircles;
1516
}
1617

1718
- (id)initWithCircles:(int)numberOfCircles {
@@ -33,12 +34,20 @@ - (id)initWithCircles:(int)numberOfCircles {
3334
- (void)setFilledCircles:(int)filledCircles {
3435
NSAssert(filledCircles <= _circleViews.count, @"Can't fill more circles than provided.");
3536
NSAssert(filledCircles >= 0, @"Can't fill < 0 circles.");
36-
37-
for (int i = 0; i < filledCircles; i++) {
37+
_filledCircles = filledCircles;
38+
[self updateViews];
39+
}
40+
41+
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
42+
[self updateViews]; // table view cell fix
43+
}
44+
45+
- (void)updateViews {
46+
for (int i = 0; i < _filledCircles; i++) {
3847
UIView* circle = [_circleViews objectAtIndex:_circleViews.count - i - 1];
3948
circle.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1.0];
4049
}
41-
for (int i = filledCircles; i < _circleViews.count; i++) {
50+
for (int i = _filledCircles; i < _circleViews.count; i++) {
4251
UIView* circle = [_circleViews objectAtIndex:_circleViews.count - i - 1];
4352
circle.backgroundColor = [UIColor clearColor];
4453
}
@@ -53,4 +62,6 @@ - (void)layoutSubviews {
5362
}
5463
}
5564

65+
66+
5667
@end

0 commit comments

Comments
 (0)