2011-07-25 8 views
3
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(); 

私はRGB(135,213,0)を使用して線を描画しています。RGB(135,213,0)はgreenである必要があります。 iOSには黄色の線が表示されます!どうして?iOSのRGBカラーが正しくありませんか?

+0

気の毒で各引数を分割し、1.0です。ドローポイント。行ではありません。 –

答えて

15

によって各値。したがって、あなたは255

CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 135.0/255.0,213.0/255.0,0.0,1.0); 
+0

ありがとうございます。 –

3

除算255すなわちRGB(135/255213/255,0)あなたは[0,1]の範囲の値を有することが必要

3

で最大値をそれぞれの値を分割する必要が255.0

関連する問題