绘制三角形矩形

 /**绘制三角形*/
    CGContextRef contextRef=UIGraphicsGetCurrentContext();
    CGContextMoveToPoint(contextRef, 100, 100);
    CGContextAddLineToPoint(contextRef, 100, 200);
    CGContextAddLineToPoint(contextRef, 200, 200);
    
    CGContextMoveToPoint(contextRef, 100, 100);
    CGContextAddLineToPoint(contextRef, 200, 200);
    CGContextSetStrokeColorWithColor(contextRef, [UIColor redColor].CGColor);
    CGContextStrokePath(contextRef);
    
     
    /**绘制矩形*/
    CGContextRef contextRef=UIGraphicsGetCurrentContext();
    CGContextAddRect(contextRef, CGRectMake(50, 100, 200, 200));
    CGContextSetRGBFillColor(contextRef, 1, 0, 0, 1.0);
    CGContextFillPath(contextRef);
    
    /**绘制矩形*/
    CGContextMoveToPoint(contextRef, 100, 100);
    CGContextAddLineToPoint(contextRef, 200, 100);
    CGContextMoveToPoint(contextRef, 100, 100);
    CGContextAddLineToPoint(contextRef, 100, 200);
    CGContextMoveToPoint(contextRef, 100, 200);
    CGContextAddLineToPoint(contextRef, 200, 200);
    CGContextMoveToPoint(contextRef, 200, 100);
    CGContextAddLineToPoint(contextRef, 200, 200);
    CGContextStrokePath(contextRef);
    

 

posted @ 2015-03-31 22:06  曹县三胖暴打大猩猩  阅读(172)  评论(0编辑  收藏  举报