美文网首页
图形绘制CoreGraphics

图形绘制CoreGraphics

作者: 阿龍飛 | 来源:发表于2016-12-22 12:07 被阅读43次

    iOS图形绘制CoreGraphics篇http://www.tuicool.com/articles/BfE7F3r
    CoreGraphics 框架之梯度渐变http://www.tuicool.com/articles/YzUVRbR

    CoreGraphics中主要分三种,
    1,UIGraphicsGetCurrentContext()函数开头的绘制.
    2,UIGraphicsBeginImageContextWithOptions()函数开头的绘制,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 3,CGPathCreateMutable()函数开头的绘制, 其中,UIGraphicsGetCurrentContext()函数需在view 的 drawInRect方法中调用.

    简单绘制圆形

    - (void)drawRect:(CGRect)rect {
        CGContextRef contextRef = UIGraphicsGetCurrentContext();
        //绘制圆形:方式一
        CGContextSetStrokeColorWithColor(contextRef, [UIColor blueColor].CGColor);
        CGContextSetFillColorWithColor(contextRef, [UIColor redColor].CGColor);
        CGContextAddArc(contextRef, 100, 100, 20.0, -180 * M_PI / 180, 180 * M_PI / 180, NO);
        CGContextDrawPath(contextRef, kCGPathFillStroke);
        //绘制圆形:方式二
        CGContextAddEllipseInRect(contextRef, CGRectMake(0, 0, 80, 80));
        CGContextDrawPath(contextRef, kCGPathFillStroke);
    }
    

    相关文章

      网友评论

          本文标题:图形绘制CoreGraphics

          本文链接:https://www.haomeiwen.com/subject/dagcvttx.html