File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed
Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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;
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments