drawrect

来源:互联网 发布:幼儿园淘宝节活动好吗 编辑:程序博客网 时间:2024/06/04 17:56


     // 1. 获取当前的图形上下文

     CGContextRef ctx = UIGraphicsGetCurrentContext();

     

     // 2. 在上下文中绘制图形(拼接路径)

     // 2.1 设置一个起点

     CGContextMoveToPoint(ctx, 20, 20);

     // 2.2 添加一条直线到(100, 100)这个点

     CGContextAddLineToPoint(ctx, 100, 20);

     

     

     // 2.3 再重新设置一个起点

     CGContextMoveToPoint(ctx, 5, 50);

     // 2.4 再添加一条线

     CGContextAddLineToPoint(ctx, 115, 50);

     

     

     // 3. 把上下文渲染显示

    // StrokePath 表示把路径以空心的形式渲染出来。

     CGContextStrokePath(ctx);

 }


0 0
原创粉丝点击