1

以下代码在 ios6 中按预期工作(我在自定义 UIView 的 drawRect 方法中绘制折线图)

//evaluate if the cross is inside the envelope
        BOOL crossIsInside  = CGPathContainsPoint(envelopePath, NULL, CGPointMake(crossX, crossY), NO);
        CGContextSetStrokeColor (cgx, (crossIsInside) ? CGColorGetComponents([[UIColor greenColor]CGColor]) :
                                                        CGColorGetComponents([[UIColor redColor]CGColor]));


        // draw an X
        CGContextMoveToPoint(cgx, crossX-crossSize, crossY-crossSize);
        CGContextAddLineToPoint(cgx,crossX+crossSize, crossY+crossSize);
        CGContextMoveToPoint(cgx, crossX-crossSize, crossY+crossSize);
        CGContextAddLineToPoint(cgx,crossX+crossSize, crossY-crossSize);
        CGContextDrawPath(cgx, kCGPathStroke);

初始评估有效,但线条变为黑色(不是红色或绿色)。

有任何想法吗?

谢谢!

4

0 回答 0