【发布时间】:2014-12-31 21:58:49
【问题描述】:
我有一个自定义的“点”视图,它是一个带有边框和背景颜色的圆圈,类似于 iOS 7+ 左上角显示信号强度的点。
点可以填充也可以不填充。
填充点:
未填充的点:
问题:在我启动应用程序的 20-30% 的时间里,未填充的点会以黄色背景显示,即使明确指定了白色。
这里是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 永远不会被设置为黄色。只有您看到的蓝色作为边框。
什么可能导致这些有时显示为黄色?
【问题讨论】:
标签: ios iphone core-graphics