【问题标题】:how to fill through color in CGContextStrokeLineSegments?如何在 CGContextStrokeLineSegments 中填充颜色?
【发布时间】:2011-07-09 08:12:22
【问题描述】:

我正在使用代码来绘制一个三角形,但是如何在其中填充颜色。

    CGContextSetRGBStrokeColor(c, 255, 0, 255, 1);
//CGContextSetRGBStrokeColor(c, 1.0, 1.0, 1.0, 1.0);
// Drawing with a blue fill color
CGContextSetRGBFillColor(c, 0.0, 0.8, 1.0, 1.0);
CGPoint points[6] = { CGPointMake(142, 200), CGPointMake(150, 250),
CGPointMake(150, 250), CGPointMake(135, 250),
CGPointMake(135, 250), CGPointMake(142, 200) };
CGContextStrokeLineSegments(c, points, 6);

【问题讨论】:

    标签: iphone ipad iphone-sdk-3.0


    【解决方案1】:

    先创建路径,然后填充:

    CGContextSetRGBFillColor(c, 0.0, 0.8, 1.0, 1.0);
    CGPoint points[6] = { CGPointMake(142, 200), CGPointMake(150, 250),
        CGPointMake(150, 250), CGPointMake(135, 250),
        CGPointMake(135, 250), CGPointMake(142, 200) };
    CGContextAddLines(c, points, 6);
    CGContextClosePath(c);
    CGContextFillPath(c);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-24
      • 1970-01-01
      • 1970-01-01
      • 2012-04-24
      • 1970-01-01
      • 2019-12-11
      • 2012-01-24
      • 1970-01-01
      相关资源
      最近更新 更多