I have a custom 'Dot' view that is a circle with a border and background color, similar to the dots in the upper-left hand corner of iOS 7+ that show signal strength.
A dot can either be filled or not filled.
Filled dot:
Not filled dot:
The problem: 20-30% of the time I launch the app, non-filled dots appear with a yellow background, even though white is explicitly specified.
Here is the code in drawRect:
- (void)drawRect:(CGRect)rect
{
CGRect borderRect = CGRectInset(rect, 3, 3);
CGContextRef ctx = UIGraphicsGetCurrentContext();
if (self.filled) {
CGContextSetFillColor(ctx, CGColorGetComponents([self.color CGColor]));
} else {
CGContextSetFillColor(ctx, CGColorGetComponents([[UIColor whiteColor] CGColor]));
}
CGContextSetStrokeColor(ctx, CGColorGetComponents([self.color CGColor]));
CGFloat lineWidth = rect.size.height/10;
if (lineWidth < 1) {
lineWidth = 1.0;
}
CGContextSetLineWidth(ctx, lineWidth);
CGContextFillEllipseInRect(ctx, borderRect);
CGContextStrokeEllipseInRect(ctx, borderRect);
CGContextFillPath(ctx);
}
self.color
is never being set to yellow. Only the blue color you see as a border.
What could be causing these to sometimes appear yellow?
Aucun commentaire:
Enregistrer un commentaire