zoukankan      html  css  js  c++  java
  • Quartz 2D

    // 1.获得图形上下文

        CGContextRef ctx = UIGraphicsGetCurrentContext();

        

        // 2.拼接图形(路径)

        // 设置线段宽度

        CGContextSetLineWidth(ctx, 10);

        

        // 设置线段头尾部的样式

        CGContextSetLineCap(ctx, kCGLineCapRound);

        

        // 设置线段转折点的样式

        CGContextSetLineJoin(ctx, kCGLineJoinRound);

        

        // 设置线段颜色

        CGContextSetRGBStrokeColor(ctx, 1, 0, 0, 1);

        // 设置一个起点

        CGContextMoveToPoint(ctx, 10, 10);

        // 添加一条线段到(100, 100)

        CGContextAddLineToPoint(ctx, 100, 100);

        

        // 渲染一次

        CGContextStrokePath(ctx);

    // set : 同时设置为实心和空心颜色

        // setStroke : 设置空心颜色

        // setFill : 设置实心颜色

        [[UIColor whiteColor] set];

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

     
     

     // 关闭路径(连接起点和最后一个点)

        CGContextClosePath(ctx);

      // 1.取得图片

        UIImage *image = [UIImage imageNamed:@"me"];

        

        // 2.画(三种都可以,但是显示效果不同)

    //    [image drawAtPoint:CGPointMake(50, 50)];

    //    [image drawInRect:CGRectMake(0, 0, 150, 150)];

        [image drawAsPatternInRect:CGRectMake(0, 0, 200, 200)];

        

        // 3.画文字

        NSString *str = @"为xxx所画";

        [str drawInRect:CGRectMake(0, 180, 100, 30) withAttributes:nil];

    // 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:50];

        [str drawInRect:cubeRect withAttributes:attrs];

  • 相关阅读:
    JS的构造函数
    Wdcp在安装memcached出现错误的解决办法
    mac 下 xampp 多域名 多站点 多虚拟主机 配置
    JS快速获取图片宽高的方法
    全文检索引擎Solr系列——整合MySQL、MongoDB
    php:获取浏览器的版本信息
    css3 media媒体查询器用法总结
    转:利用node压缩、合并js,css,图片
    火车进站
    三角形有向面积
  • 原文地址:https://www.cnblogs.com/qingsongeasy/p/3662916.html
Copyright © 2011-2022 走看看