The power leverl pie was not properly rendered when the cell was selected : the grey part was hidden.

This commit is contained in:
ylecollen
2014-12-22 13:31:54 +01:00
parent 6a7b809d98
commit 721071bb65
2 changed files with 26 additions and 3 deletions
+25 -3
View File
@@ -95,9 +95,7 @@
// draw a rounded view
[self.powerContainer.layer setCornerRadius:radius];
// the default body color is gray
self.powerContainer.backgroundColor = [UIColor lightGrayColor];
self.powerContainer.backgroundColor = [UIColor clearColor];
// draw the pie
CALayer* layer = [self.powerContainer layer];
@@ -107,6 +105,30 @@
[powerContainerLayer removeFromSuperlayer];
}
// the background cell color is hidden the cell is selected.
// so put in grey the cell background triggers a weird display (the background grey is hidden but not the red part).
// add an other layer fixes the UX.
if (!backgroundContainerLayer) {
backgroundContainerLayer = [CAShapeLayer layer];
[backgroundContainerLayer setZPosition:0];
[backgroundContainerLayer setStrokeColor:NULL];
backgroundContainerLayer.fillColor = [UIColor lightGrayColor].CGColor;
// build the path
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, radius, radius);
CGPathAddArc(path, NULL, radius, radius, radius, 0 , 2 * M_PI, 0);
CGPathCloseSubpath(path);
[backgroundContainerLayer setPath:path];
CFRelease(path);
// add the sub layer
[layer addSublayer:backgroundContainerLayer];
}
// create the red layer
powerContainerLayer = [CAShapeLayer layer];
[powerContainerLayer setZPosition:0];