画图1

作者: nothing_c | 来源:发表于2016-10-30 23:30 被阅读2次

基础知识


//系统内部绘图的方法视图,设置frame时才会调用

- (void)drawRect:(CGRect)rect {

// Drawing code

//[super drawRect:rect];

//画一条线

//创建一个绘图缓冲区域

CGContextRef context =UIGraphicsGetCurrentContext();

//设置画笔的线的宽度和颜色及边帽

{

//宽度

CGContextSetLineWidth(context, 8);

//颜色

CGContextSetRGBStrokeColor(context, 1, 0, 0, 1);

//边帽设置,边帽可以是线条不会出现裂痕

CGContextSetLineCap(context,kCGLineCapRound);

//线的结合部分的样式

CGContextSetLineJoin(context,kCGLineJoinRound);

}

//画一条线

//    //起点

//    CGContextMoveToPoint(context, 20, 80);

//    //终点

//    CGContextAddLineToPoint(context, 100, 180);

//    CGContextAddLineToPoint(context, 180, 80);

//    //封闭区域(三角形)

//    CGContextClosePath(context);

//    //圆形

//    CGContextAddArc(context, 200, 200, 100, 0, M_PI*2, 1);

//    //设置填充色

////    [[UIColor orangeColor] set];

//    CGContextSetRGBFillColor(context, 0, 1, 0, 1);

//    //填充颜色

//    CGContextFillPath(context);

//    //椭圆

//    //CGContextAddEllipseInRect(context, CGRectMake(100, 100, 100, 200));

//    //椭圆边框

//    CGContextStrokeEllipseInRect(context, CGRectMake(100, 100, 100, 200));

//    //设置填充色

//    [[UIColor orangeColor] set];

//    //绘图并直接填充颜色

//    CGContextFillEllipseInRect(context, CGRectMake(100, 100, 100, 200));

//    //矩形/正方形

//    CGContextAddRect(context, CGRectMake(100, 100, 200, 100));

//    //文字

//    NSString *string = @"文字";

//   [string drawInRect:CGRectMake(100, 100, 100, 100) withAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:40],NSForegroundColorAttributeName:[UIColor greenColor]}];

//    CGContextAddArc(context, 200, 200, 100, 0, M_PI*2, 1);

//    [[UIColor orangeColor] set];

//    CGContextFillPath(context);

//    [string drawAtPoint:CGPointMake(180, 180) withAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:40],NSForegroundColorAttributeName:[UIColor greenColor]}];

//绘制图片

UIImage*image = [UIImageimageNamed:@"8.jpg"];

[imagedrawInRect:CGRectMake(20, 100, 200, 200)];

//绘图

CGContextStrokePath(context);

}

相关文章

  • 画图1

    基础知识 //系统内部绘图的方法视图,设置frame时才会调用 - (void)drawRect:(CGRect)...

  • 2020.11.18工作日志

    休半天上午睡到9点10多分,起来画图到12:20。下午1:30开会画图~一天就在画图中过了~ 总结:画图的质量有待...

  • Python之MatPlotLib使用教程

    1.Matplotlib简介 Matplotlib是非常强大的python画图工具 Matplotlib可以画图线...

  • 教研日记(1)——画图

    教研第7天,我们放半天假!此时此刻在享受美食!每天沉迷于教研中无法自拔,所以趁着这会来叨叨一下教研日常。 ...

  • 丹心入画图(1)

    长篇小说《丹心入画图》 第一章 初见良人1 夜色微寒,一轮皎月破云而出。 清辉洒下,亭台楼阁、玲珑山石、花草树木...

  • Matplotlib画图教程(1)

    plt.axesx轴plt.axis y轴 线条样式线条颜色:标准的颜色:blue,red,green简写代...

  • Matplotlib画图浅析(1)

    Matplotlib画图浅析 标签(空格分隔): python 安装与导入 首先,安装库Matplotlib不必再...

  • 批量ROC

    1、建模 2、画图 3、保存

  • matplotlib--python的数据可视化

    1.画图 画图样式 数据线的样式设置颜色缩写 全程b blue...

  • Matplotlib教程-初级

    [TOC] 1. 画图——基础 了解图的基本组成部分 2. 画图——样式 数据线的样式设置 3. 画图——公式Te...

网友评论

      本文标题:画图1

      本文链接:https://www.haomeiwen.com/subject/bniuuttx.html