使用内置颜色填充矩形效果很好,但是当尝试使用RGB代码自定义颜色时将无法正常工作。
CGContextRef ctx = UIGraphicsGetCurrentContext();
UIColor* color = [UIColor colorWithRed:80 green:80 blue:80 alpha:1];
CGContextAddEllipseInRect(ctx, circleRect);
CGColorSpaceRef cgRef = CGColorGetColorSpace([color CGColor]);
CGContextSetStrokeColorSpace(ctx, cgRef);
CGContextSetStrokeColorWithColor(ctx, [color CGColor]);
CGContextStrokeEllipseInRect(ctx, circleRect);
,但是使用UIColor.grayColor
作为颜色,效果很好。
我也尝试过不修改色彩空间,没有任何作用
答案 0 :(得分:0)
自定义RGB代码的参数必须为CGFloats。
UIColor* color = [UIColor colorWithRed:80.0/255.0 green:80.0/255.0 blue:80.0/255.0 alpha:1];
将是指定自定义RGB颜色的正确方法