XCODE4.5
IOS 6.0
能画图,填充颜色没效果。代码如下。
CGContextRef context = UIGraphicsGetCurrentContext(); 
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextSetFillColorWithColor(context, [UIColor  redColor].CGColor);
CGContextSetLineWidth(context, 1.0);
CGContextMoveToPoint(context, 10, 10);
CGContextAddLineToPoint(context, 10, 100);
CGContextAddLineToPoint(context, 100, 100);
CGContextAddLineToPoint(context, 100, 10);
CGContextAddLineToPoint(context, 10, 10);
CGContextStrokePath(context);
CGContextFillPath(context);

解决方案 »

  1.   

        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
        CGContextSetFillColorWithColor(context, [UIColor  redColor].CGColor);
        CGContextSetLineWidth(context, 1.0);
        CGContextMoveToPoint(context, 10, 10);
        CGContextAddLineToPoint(context, 10, 100);
        CGContextAddLineToPoint(context, 100, 100);
        CGContextAddLineToPoint(context, 100, 10);
        CGContextAddLineToPoint(context, 10, 10);
        CGContextClosePath(context);                                                                              
    //    CGContextStrokePath(context);
        CGContextDrawPath(context, kCGPathFillStroke);
    这样没问题了