Skip to content

Instantly share code, notes, and snippets.

@fhefh2015
Forked from ldong/Quartz2D.md
Created March 17, 2016 10:18
Show Gist options
  • Save fhefh2015/bf4a53b56a74f17f37d9 to your computer and use it in GitHub Desktop.
Save fhefh2015/bf4a53b56a74f17f37d9 to your computer and use it in GitHub Desktop.
Quartz 2D

Quartz 2D Notes

  CGContextRef context = ();
    //设置起始点
    CGContextMoveToPoint (context, 160, 100);
    CGContextAddLineToPoint (context, 100, 180);
    CGContextAddLineToPoint (context, 160, 180);
    // 设置边界
    [[UIColor blackColor] setStroke];
    //填充颜色
    [[UIColor redColor] setFill];
    //绘制路径
    CGContextDrawPath(context, kCGPathFillStroke);
     
  //获取上下文
    CGContextRef context = UIGraphicsGetCurrentContext();
     
    CGRect rect = CGRectMake(50, 200, 200, 200);
    //是否有边框
//    UIRectFrame(rect);
    //矩形中添加一个椭圆
    CGContextAddEllipseInRect(context, rect);
     
    [[UIColor greenColor] setStroke];
     
    //设置绿色背景
    [[UIColor greenColor] setFill];
     
    // 3. 绘制路径
    CGContextDrawPath(context, kCGPathFillStroke);

Reference

iOS开发-Quartz2D初识

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment