今天初始Quartz2D,我好激动啊,也好开心,莫名的会喜欢带有图形相关的课程……

好啦,闲话少说,今天用Quartz2D方法画了最最爱的大白。迫不及待的想要和大家分享。

1、首先实例化了view

2、在实例化的view的写代码就可以了,是不是很简单。

//不允许直接调用drawRect方法,使用setNeedsDisplay 间接调用drawRect方法

- (void)drawRect:(CGRect)rect {

//获得图形上下文

//获得当前图形上下文

CGContextRef  context = UIGraphicsGetCurrentContext();

//头

[self drawHeader:context];

[self drawHeader2:context];

//眼睛

[self drawEye:context];

[self drawEye2:context];

[self drawEye3:context];

[self drawEye4:context];

[self drawEyeLine:context];

//身体

[self drawBody:context];

[self drawBody2:context];

[self drawBody3:context];

[self drawBody4:context];

[self drawBody5:context];

//脚

[self drawBody6:context];

[self drawBody7:context];

}

#pragma mark 画头(上边)

- (void)drawHeader :(CGContextRef) context{

// 1.  圆心 ,半径,起始和终止角度 ,方向

CGContextAddArc(context, self.frame.size.width/2, 150, 50, 0,- M_PI, 1);

CGContextStrokePath(context);

}

#pragma mark 画头(下边)

- (void)drawHeader2 :(CGContextRef) context{

// 1.  圆心 ,半径,起始和终止角度 ,方向

CGContextAddArc(context, self.frame.size.width/2, 150, 50, 0,- M_PI, 0);

CGContextStrokePath(context);

}

#pragma mark 眼睛(左下)

-(void)drawEye:(CGContextRef) context{

CGContextAddArc(context, 162, 160, 10, 0,- M_PI, 0);

CGContextFillPath(context);

}

#pragma mark 眼睛(左上)

-(void)drawEye2:(CGContextRef) context{

CGContextAddArc(context, 162, 160, 10, 0,- M_PI, 1);

CGContextFillPath(context);

}

#pragma mark 眼睛(右下)

-(void)drawEye3:(CGContextRef) context{

CGContextAddArc(context, 212, 160, 10, 0,- M_PI, 0);

CGContextSetLineWidth(context, 3);

CGContextFillPath(context);

}

#pragma mark 眼睛(右上)

-(void)drawEye4:(CGContextRef) context{

CGContextAddArc(context, 212, 160, 10, 0,- M_PI, 1);

CGContextSetLineWidth(context, 3);

CGContextFillPath(context);

}

#pragma mark 眼睛连线

- (void)drawEyeLine :(CGContextRef) context{

//移动到某一点

CGContextMoveToPoint(context, 162, 160);

//添加一条线

CGContextAddLineToPoint(context, 212, 160);

CGContextSetLineWidth(context, 3);//线宽

//    3.绘制图形

CGContextStrokePath(context);

}

#pragma mark  身体(左) 贝塞尔

- (void)drawBody:(CGContextRef) context{

CGPoint p1=CGPointMake(152, 185);

CGPoint p2=CGPointMake(20, 290);

CGPoint p3=CGPointMake(120, 400);

CGContextMoveToPoint(context, p1.x, p1.y);

CGContextAddQuadCurveToPoint(context, p2.x, p2.y, p3.x, p3.y);

CGContextStrokePath(context);

}

#pragma mark  身体(右)贝塞尔

- (void)drawBody2:(CGContextRef) context{

CGPoint p1=CGPointMake(222, 185);

CGPoint p2=CGPointMake(355, 290);

CGPoint p3=CGPointMake(255, 400);

CGContextMoveToPoint(context, p1.x, p1.y);

CGContextAddQuadCurveToPoint(context, p2.x, p2.y, p3.x, p3.y);

CGContextStrokePath(context);

}

#pragma mark  身体(下)贝塞尔

- (void)drawBody3:(CGContextRef) context{

CGPoint p1=CGPointMake(120, 400);//第一个点

CGPoint p2=CGPointMake(187.5, 450);//中间的点

CGPoint p3=CGPointMake(255, 400);//第二个点

CGContextMoveToPoint(context, p1.x, p1.y);

CGContextAddQuadCurveToPoint(context, p2.x, p2.y, p3.x, p3.y);

CGContextStrokePath(context);

}

#pragma mark  身体(左胳膊) 贝塞尔

- (void)drawBody4:(CGContextRef) context{

CGPoint p1=CGPointMake(148, 180);

CGPoint p2=CGPointMake(0, 300);

CGPoint p3=CGPointMake(103, 380);

CGContextMoveToPoint(context, p1.x, p1.y);

CGContextAddQuadCurveToPoint(context, p2.x, p2.y, p3.x, p3.y);

CGContextStrokePath(context);

}

#pragma mark  身体(右胳膊)贝塞尔

- (void)drawBody5:(CGContextRef) context{

CGPoint p1=CGPointMake(226, 180);

CGPoint p2=CGPointMake(375, 300);

CGPoint p3=CGPointMake(272, 380);

CGContextMoveToPoint(context, p1.x, p1.y);

CGContextAddQuadCurveToPoint(context, p2.x, p2.y, p3.x, p3.y);

CGContextStrokePath(context);

}

#pragma mark 脚(左)贝塞尔

- (void)drawBody6:(CGContextRef) context{

CGPoint p1=CGPointMake(120, 400);

CGPoint p2=CGPointMake(140, 450);

CGPoint p3=CGPointMake(175, 424);

CGContextMoveToPoint(context, p1.x, p1.y);

CGContextAddQuadCurveToPoint(context, p2.x, p2.y, p3.x, p3.y);

CGContextStrokePath(context);

}

#pragma mark 脚(左)贝塞尔

- (void)drawBody7:(CGContextRef) context{

CGPoint p1=CGPointMake(255, 400);

CGPoint p2=CGPointMake(234, 450);

CGPoint p3=CGPointMake(199, 424);

CGContextMoveToPoint(context, p1.x, p1.y);

CGContextAddQuadCurveToPoint(context, p2.x, p2.y, p3.x, p3.y);

CGContextStrokePath(context);

}

@end

原谅小菜鸟见得世面少,不过,真的有认真地写了代码,请喜欢大白的童鞋,拿去试试吧,大白送给你们。

今天学习很开心,明天继续加油,大家一起加油哟~~

Quartz2D 画大白的更多相关文章

  1. 【二次元的CSS】—— 用 DIV + CSS3 画大白(详解步骤)

    原本自己也想画大白,正巧看到一位同学(github:https://github.com/shiyiwang)也用相同的方法画了. 且细节相当到位.所以我就fork了一下,在此我也分享一下.同时,我也 ...

  2. AJ学IOS(34)UI之Quartz2D画画板的实现

    AJ分享,必须精品 效果: 实现过程: 首先用storyboard搭建界面,没有什么好说的. 然后就是注意的功能了,这里用了触摸事件来搭配Quartz2D的路径来画画. 思路就是把路径放到数组中 @p ...

  3. 用纯CSS画大白

    纯CSS打造网页大白知识点:      首先要把大白分割,整体baymax中包含header(eye1,eye2,mouth),torso(heart),belly(cover),l-bigfinge ...

  4. AJ学IOS(29)UI之Quartz2D自定义下载控件_画各种图形

    AJ分享,必须精品 效果 自定义控件过程 主要过程在上一篇里有介绍了,这里主要介绍下代码实现 先做好要放的view 然后实现呢主要就是四步: 1:获取上下文 2:拼接路径 3:把路径添加到上下文. 4 ...

  5. Quartz2D之绘制一个简单的机器猫

    学习iOS有一段时间了,在博客园也默默的潜水了两个月,见识了很多大神,收获不少. 今天整理笔记,发现忘记的不少,我感觉需要及时的整理一下了,同时也把做的小东西贴上来和大家分享一下. 最近学习了Quar ...

  6. iOS开发——UI进阶篇(十五)Quartz2D介绍

    一.Quartz2D简介 1.什么是Quartz2DQuartz 2D是一个二维绘图引擎,同时支持iOS和Mac系统 Quartz 2D能完成的工作绘制图形 : 线条\三角形\矩形\圆\弧等绘制文字绘 ...

  7. iOS开发UI篇—Quartz2D简单介绍

    iOS开发UI篇—Quartz2D简单介绍 一.什么是Quartz2D Quartz 2D是⼀个二维绘图引擎,同时支持iOS和Mac系统 Quartz 2D能完成的工作: 绘制图形 : 线条\三角形\ ...

  8. 【iOS】Quartz2D简单介绍

    一.什么是Quartz2D Quartz 2D是⼀个二维绘图引擎,同时支持iOS和Mac系统 Quartz 2D能完成的工作: 绘制图形 : 线条\三角形\矩形\圆\弧等 绘制文字 绘制\生成图片(图 ...

  9. Quartz2D学习笔记(1)

    ********************************** 简介 *************************************** Quartz2D是⼀个二维绘图引擎,同时支持 ...

随机推荐

  1. 同时使用Junit4的@Parameterized参数化测试和Spring容器

    转载:http://www.jianshu.com/p/d191fe54915f 整合Spring容器 @SpringApplicationConfiguration(classes = Applic ...

  2. iptables删除规则

    查看nat规则: iptables -t nat -nL --line-number 添加规则是-A和-I,-A是添加到末尾,-I是添加到指定位置,默认添加到最前面.删除使用-D,也就是原来“ipta ...

  3. sql语句-ALTER TABLE

    在工作中常遇到要维护数据库表的列,这里主要介绍sql语句中的ALTER TABLE 语句.ALTER TABLE 语句用于在已有的表中添加.修改或删除列. 如需在表中添加列,请使用下列语法: ALTE ...

  4. 通过JS简单实现图片缩放

    ;display: none;cursor: pointer;} #FullScreenDiv{;display: none;background-color: #919191;filter: alp ...

  5. 【cocos2d-js官方文档】一、搭建 Cocos2d-JS 开发环境

    http://blog.csdn.net/qinning199/article/details/40395085

  6. CRM客户关系管理系统 北京易信软科信息技术有限公司

    北京易信软科信息技术有限公司 推出大型erp系统,库存管理系统,客户关系管理系统,车辆登记管理系统,员工管理系统,采购管理系统,销售管理系统,为您的企业提供最优质的产品服务 北京易信软科您可信赖的北京 ...

  7. sax/dom/jdom/dom4j的区别

    sax/dom/jdom/dom4j的区别[转] 博客分类: xml   网上能够查到很多的4种解析方式的区别,我再做一下摘录和总结,顺带给自己做个备份. SAX sax分析器在对xml文档进行分析时 ...

  8. hive内部表、外部表、分区表、视图

    1.Table 内部表 1).与数据库中的Table在概念上是类似的 2).每一个Table在Hive中都有一个相应的目录存储数据 3).所有的Table数据(不包括 External Table) ...

  9. 习课的redis配置记录

    <!-- redis begin --> <dependency> <groupId>redis.clients</groupId> <artif ...

  10. 仿QQ消息气泡提醒

    https://github.com/dkmeteor/Bubble-Notification   感谢这位作者,本例子只是封装了一下源码. 这是jar下载地址 下载之后只要引用就好.下面是一个最简单 ...