mmmmmmmm
// // AView.m // AutoLayout // // Created by ZhuYi on 16/5/24. // Copyright © 2016年 ZY. All rights reserved. // #import "AView.h" @implementation AView // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code UIImage *image = [UIImage imageNamed:@"dropdown_anim__0005"]; [image drawInRect:CGRectMake(, , rect.size.width, rect.size.height)]; // [image drawAsPatternInRect:CGRectMake(0, 0, rect.size.width, rect.size.height)]; } /** * 画三角形 */ void drawTriangel(){ //获得当前图形的上下文 CGContextRef ctx = UIGraphicsGetCurrentContext(); //设置七点 CGContextMoveToPoint(ctx, , ); CGContextAddLineToPoint(ctx, , ); CGContextAddLineToPoint(ctx, , ); // CGContextAddLineToPoint(ctx, 0, 0); //关闭路径 CGContextClosePath(ctx); // [[UIColor redColor] setFill]; // [[UIColor redColor] set]; CGContextSetRGBFillColor(ctx, , , , ); CGContextFillPath(ctx); } /** * 画矩形 */ void drawRect(){ CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextAddRect(ctx, CGRectMake(, , , )); // [[UIColor redColor] setStroke]; CGContextSetRGBStrokeColor(ctx, , , , ); CGContextStrokePath(ctx); } /** * 设置状态 */ void set(){ CGContextRef ctx = UIGraphicsGetCurrentContext(); //设置开头和结尾的样式 CGContextSetLineCap(ctx, kCGLineCapRound); //设置转折点的样式 CGContextSetLineJoin(ctx, kCGLineJoinRound); CGContextMoveToPoint(ctx, , ); CGContextAddLineToPoint(ctx, , ); CGContextSetLineWidth(ctx, ); CGContextSetRGBStrokeColor(ctx, , , , ); CGContextStrokePath(ctx); CGContextMoveToPoint(ctx, , ); CGContextAddLineToPoint(ctx, , ); CGContextAddLineToPoint(ctx, , ); CGContextSetRGBStrokeColor(ctx, , , , ); CGContextSetLineWidth(ctx, ); CGContextStrokePath(ctx); } /** * 画椭圆 */ void ellipse(){ CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(ctx, , , , ); CGContextSetLineWidth(ctx, ); CGContextAddEllipseInRect(ctx, CGRectMake(, , , )); CGContextStrokePath(ctx); } /** * 画圆弧 */ void arr(){ CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextAddArc(ctx, , , , , -M_PI_4, ); CGContextSetLineWidth(ctx, ); CGContextSetRGBStrokeColor(ctx, , , , ); CGContextStrokePath(ctx); } /** * 画圆弧 */ void cusarr(){ CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextMoveToPoint(ctx, , ); CGContextAddLineToPoint(ctx, , ); CGContextAddArc(ctx, , , , M_PI_2, M_PI, ); CGContextClosePath(ctx); CGContextFillPath(ctx); } /** * 画文字 */ void drawText() { // 1.获得上下文 CGContextRef ctx = UIGraphicsGetCurrentContext(); // 2.画矩形 CGRect cubeRect = CGRectMake(, , , ); CGContextAddRect(ctx, cubeRect); // 3.显示所绘制的东西 CGContextFillPath(ctx); // 4.画文字 NSString *str = @"哈哈哈哈Good morning hello hi hi hi hi"; // [str drawAtPoint:CGPointZero withAttributes:nil]; NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; // NSForegroundColorAttributeName : 文字颜色 // NSFontAttributeName : 字体 attrs[NSForegroundColorAttributeName] = [UIColor redColor]; attrs[NSFontAttributeName] = [UIFont systemFontOfSize:]; [str drawInRect:cubeRect withAttributes:attrs]; } void drawImage() { // 1.取得图片 UIImage *image = [UIImage imageNamed:@"me"]; // 2.画 // [image drawAtPoint:CGPointMake(50, 50)]; // [image drawInRect:CGRectMake(0, 0, 150, 150)]; [image drawAsPatternInRect:CGRectMake(, , , )]; // 3.画文字 // NSString *str = @"为xxx所画"; // [str drawInRect:CGRectMake(0, 180, 100, 30) withAttributes:nil]; } /** * 矩阵操作和上下文栈 */ void juzhencaozuo(){ CGContextRef ctx = UIGraphicsGetCurrentContext(); //保存上下文栈 CGContextSaveGState(ctx); //矩阵操作 CGContextRotateCTM(ctx, M_PI_4 * 0.3); CGContextScaleCTM(ctx, 0.5, 0.5); CGContextTranslateCTM(ctx, , ); CGContextAddRect(ctx, CGRectMake(, , , )); CGContextStrokePath(ctx); //回复上下文栈 CGContextRestoreGState(ctx); CGContextAddEllipseInRect(ctx, CGRectMake(, , , )); CGContextMoveToPoint(ctx, , ); CGContextAddLineToPoint(ctx, , ); // 矩阵操作 // CGContextScaleCTM(ctx, 0.5, 0.5); CGContextStrokePath(ctx); } /** * 裁剪 */ void caijian(){ CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSaveGState(ctx); // 0.画圆 CGContextAddEllipseInRect(ctx, CGRectMake(, , , )); // 裁剪 CGContextClip(ctx); CGContextFillPath(ctx); // 1.显示图片 UIImage *image = [UIImage imageNamed:@"me"]; [image drawAtPoint:CGPointMake(, )]; } /** * 刷帧 */ - (void)setRadios:(float)radios{ _radios = radios; [self setNeedsDisplay]; } - (void)shuazhen{ ) { self.radios = ; } CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextAddArc(ctx, , , self.radios, , M_PI * , ); CGContextStrokePath(ctx); } @end
http://www.jianshu.com/p/734b34e82135
mmmmmmmm的更多相关文章
- Android 如何有效的解决内存泄漏的问题
前言:最近在研究Handler的知识,其中涉及到一个问题,如何避免Handler带来的内存溢出问题.在网上找了很多资料,有很多都是互相抄的,没有实际的作用. 本文的内存泄漏检测工具是:LeakCana ...
- what is difference in (int)a,(int&)a,&a,int(&a) ?
This interview question come from a famous communication firm of china. : ) #include <iostream> ...
- JAVA基础学习day13--String、StringBuilder与StringBuffer与包装类
一.String 1.1.String String 类是final修饰的,是顶级类,不可被继承 String 类代表字符串.Java 程序中的所有字符串字面值(如 "abc" ) ...
- C/C++中float和double的存储结构
int main (int argc, char **argv) { float a = 1.0f; cout <<"(int&)a = "<<(i ...
- Pictures of Ascii Art
简述 指尖上的艺术 - 通过键盘上韵律般的敲敲打打,一幅幅美轮美奂的艺术作品便跃然于屏. 这样的画作,包含了无穷的创意,糅合了现代计算机科技与传统绘画艺术,难道还有比这更令人陶醉的美妙事物吗? 简述 ...
- UIProgressView-初识IOS
好几天没更新了,学的时候太紧,没时间复习了都.今天刚好有时间,多更几个. 今天复习的是UIProgressView,我们常见使用在修改某些属性的时候经常用到,比如透明度,今天我们介绍一个简单的使用例子 ...
- 项目必备!永无 bug 注释
佛祖保佑 永无bug 代码注释 // // _oo0oo_ // o8888888o // 88" . "88 // (| -_- |) // 0\ = /0 // ___/`-- ...
- C语言中,float在内存中的储存方式
浮点型变量在计算机内存中占用4字节(Byte),即32-bit. 遵循IEEE-754格式标准. 一个浮点数由2部分组成:底数m 和 指数e. ±mantissa × 2exponent (注意,公式 ...
- GPS坐标转换 百度地图API调用
1 如果GPS输出的值是DD.DDDDDDDD格式的,直接调用地图API的转换函数处理,就可以正常显示2 如果GPS输出的值是DD.MMMMMMMM格式的,就需要先进行分转度处理,然后再调API,就可 ...
随机推荐
- 企业架构研究总结(36)——TOGAF企业连续体和工具之企业连续体构成及架构划分
又回头看了之前文章的评论,本人也同样感慨这些文章的确像政治课本般的虚无缥缈,所以对费力看完却觉得无从下手的看官致以诚挚的歉意和理解,因为这个问题也同样困扰着笔者本人,而我能做的也只能是纸上谈兵.之前也 ...
- CodeForces Round
CodeForces Round 199 Div2 完了,这次做扯了,做的时候有点发烧,居然只做出来一道题,差点被绿. My submissions # When Who Problem ...
- iMac 无线键盘 无法配对
正好小编手里也有一个 Apple wireless keyboard 键盘,经测试发现确实有他所说的问题.在互联网上找了一圈儿都没找到解决方案,苹果官方也没有给出相关方案.只好自己琢磨,还好终于研究出 ...
- yowsup ( an application to use whatsapp) hack
yowsup, in python https://github.com/tgalal/yowsup try this: http://hacktracking.blogspot.com.ar/201 ...
- 使用Varnish+ESI实现静态页面的局部缓存(思路篇)
使用Varnish+ESI实现静态页面的局部缓存(思路篇) 页面静态化是搭建高性能网站必用的招式之一,页面静态化可以有效提升系统响应速度,同时也有利于搜索引擎优化.但在页面静态化后,静态页面之间包含( ...
- Trade-----HDU3401----单调队列优化的DP
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3401 题目意思: 有T天,你每天可以以API买进,BPI卖出,最多买ASI个,最多卖BSI个 最多只能 ...
- [置顶] java得到前一个月的年月日时分秒
import java.util.Calendar; /** * 得到前一个月的年月日时分秒 * @author Mr.hu * 2013-6-28上午12:00:35 * Class Explain ...
- ON COMMIT PRESERVE ROWS
定义声明式全局临时表的每个会话拥有自己的独特的临时表描述.当会话终止时,表行和临时表描述均会被删除. 有如下选项,可控制commit后临时表的状态: ON COMMIT DELETE ROWS:在执行 ...
- MS Word 目录排版
昨天整理一份把网页的内容复制粘贴到Word里的文件,碰到了这样一个问题: 网页上面也会有一级标题,二级标题,三级标题等.当我们在写博客的时候,也会去使用这些.这也就导致复制过来之后,直接生成的目录很乱 ...
- Java如何根据IP获取当前定位
当今购物.旅游等服务型的网站如此流行,我们有时候也会碰到这样网站的开发. 在开发此类网站时,为了增加用户的体验感受,我们不得不在用户刚进入网站时定位到用户所在地, 更好的为用户推荐当地产品.比如去哪儿 ...