图形绘制CoreGraphics

2016-12-22  本文已影响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);
}
上一篇下一篇

猜你喜欢

热点阅读