开发者社区> 问答> 正文

初学iPhone上用Quartz 2D画图? 400 报错

初学iPhone上用Quartz 2D画图? 400 报错

参考了An iOS 4 iPhone Graphics Drawing Tutorial using Quartz 2D这篇文章,用了30分钟在iPhone上画出了一条直线,核心代码全在drawRect这个方法中:

- ( void )drawRect:(CGRect)rect {
CGContextRef context
= UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context,
2.0 );
CGFloat componets[]
= { 0.0 , 0.0 , 1.0 , 1.0 };
CGColorSpaceRef colorspace
= CGColorSpaceCreateDeviceRGB();
CGColorRef color
= CGColorCreate(colorspace, componets);
CGContextSetStrokeColorWithColor(context, color);
CGContextMoveToPoint(context,
, );
CGContextAddLineToPoint(context,
300 , 400 );
CGContextStrokePath(context);
CGColorSpaceRelease(colorspace);
CGColorRelease(color);

}

原来在iPhone上画图也不算复杂,与Windows中原理差不多。


原文链接: http://www.cnblogs.com/speeding/archive/2011/05/27/2059462.html

展开
收起
爱吃鱼的程序员 2020-06-03 15:06:07 486 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    求 demo######http://www.techotopia.com/index.php/An_iOS_4_iPhone_Graphics_Drawing_Tutorial_using_Quartz_2D

    2020-06-03 17:13:16
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载