iOS RGB颜色不正确?

Yu-*_*Han 3 iphone rgb uicolor ipad ios

 UIGraphicsBeginImageContext(self.view.frame.size);
    [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 8.0);
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 135.0,213.0,0.0,1.0);
    CGContextBeginPath(UIGraphicsGetCurrentContext());
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(),currentPoint.x, currentPoint.y);
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
    CGContextStrokePath(UIGraphicsGetCurrentContext());
    drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)

我画一条线使用RGB(135,213,0),RGB(135,213,0)应该是绿色的.但iOS显示黄线!! 为什么?

Man*_*Way 15

您需要具有[0,1]范围内的值.因此,您需要将每个值除以255.

CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 135.0/255.0,213.0/255.0,0.0,1.0);
Run Code Online (Sandbox Code Playgroud)