码迷,mamicode.com
首页 > 其他好文 > 详细

oc初步画图

时间:2014-09-23 00:52:13      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:blog   color   ar   div   on   c   log   ad   line   

- (void)drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextMoveToPoint(context, 0, 0);
    CGContextAddRect(context,CGRectMake(100, 100, 200 , 150));
    CGContextMoveToPoint(context, 200, 175);
    CGContextAddArc(context, 200, 175, 50,-3.14/2.0,3.14/2.0, 0);
    CGContextAddLineToPoint(context, 200 , 175);
    CGContextMoveToPoint(context, 160, 175);
    CGContextAddArc(context, 160, 175, 50,-5.0*3.14/6.0,-7.0*3.14/6.0, 1);
    CGContextAddLineToPoint(context, 160, 175);
    
    //画边框
    //CGContextStrokePath(context);
    
    //设置填充色
    [[UIColor redColor] setFill];
    [[UIColor colorWithRed:0.6 green:0.4 blue:0.5 alpha:0.5] setFill];
    
    //设置边框颜色
    [[UIColor blackColor] setStroke];
    //[[UIColor greenColor] set];
    
    //EVEN-ODD, 奇偶规则填充
    CGContextDrawPath(context, kCGPathEOFillStroke);
    
    //控制点
    CGContextAddCurveToPoint(context, 50, 0, 50, 200, 100, 100);
    CGContextAddQuadCurveToPoint(context, 150, 0, 200, 100);
    CGContextStrokePath(context);
}

@end

  

oc初步画图

标签:blog   color   ar   div   on   c   log   ad   line   

原文地址:http://www.cnblogs.com/diyigechengxu/p/3986837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!