画图i

作者: Dove_Q | 来源:发表于2016-08-21 11:56 被阅读11次
               //如果希望绘制在屏幕上,应该drawRect出发
        let str: NSString = "abc"
        str.drawAtPoint(CGPoint(x: 0, y: 0), withAttributes: [
            //字体颜色
            NSForegroundColorAttributeName:UIColor.redColor(),
            //背景颜色
            NSBackgroundColorAttributeName:UIColor.whiteColor()
            ])
        
        let image = UIImage(named: "showqrcode.jpeg")
        image?.drawInRect(CGRect(x: 20, y: 20, width: 150, height: 150))
        //1. 获取当前的绘图环境(绘制到屏幕)
        //line/rectangle/arc/ellipse/
        //text/image
        let cxt = UIGraphicsGetCurrentContext() //CGContextRef
        
        //边框(Stroke),填充(Fill)
        //绘图者模式
        //设置起点
        CGContextMoveToPoint(cxt, 0, 0)
        //设置终点
        CGContextAddLineToPoint(cxt, 100, 100)
        CGContextAddLineToPoint(cxt, 0, 200)
        
        CGContextMoveToPoint(cxt, 150, 150)
        CGContextAddLineToPoint(cxt, 200, 200)
        
        CGContextSetLineWidth(cxt, 20)
        CGContextSetLineJoin(cxt, .Round)
        
        //1. 颜色设置,改变了绘图环境,cxt
//        UIColor.purpleColor().setStroke()
        //Red/Green/Blue/Alpha
//        CGContextSetStrokeColor(cxt, [1, 0, 0, 1])
        CGContextSetStrokeColorWithColor(cxt, UIColor.blueColor().CGColor)
        
        //真正绘制,当前点失效,笔离开
        CGContextStrokePath(cxt)
        
        CGContextMoveToPoint(cxt, 150, 0)
        CGContextAddLineToPoint(cxt, 150, 150)
        
        CGContextSetLineWidth(cxt, 1)
//        CGContextSetLineWidth(cxt, 10)
//        CGContextSetLineCap(cxt, .Round)
        
        //虚线:偏移 重复模式 重复数组中元素的个数
        CGContextSetLineDash(cxt, 2, [4, 4], 2)
        
        //1.
        UIColor.redColor().setStroke()
        
        CGContextStrokePath(cxt)

相关文章

  • 画图i

  • 如何画 LOGO

    Autodraw > Sketch > PS。 画图程序反色:Ctrl + Shift + i。

  • 关于seaborn的kdeplot画图时报错TypeError:

    在用seaborn的kdeplot画图时报错,TypeError: slice indices must be i...

  • css_19 fireworks快捷键

    V 切换黑鼠标U 画图K 切片I 吸色Z 放大镜空格 移动

  • 2018-05-19

    画图,画图,画图!我画完了哦[偷笑]

  • 趣玩-I draw your guess

    趣玩-I draw your guess 是一款制作图片的软件,我画图,保存到相册,你来猜。 更可以添加辅助图片,...

  • 微信小程序Canvas

    新版 画图片 旧版 画图

  • 唯美漫画图片分享图包下载

    唯美漫画图片 唯美漫画图片 唯美漫画图片 唯美漫画图片 唯美漫画图片 唯美漫画图片 更多唯美漫画图片请关注微信公众...

  • 画图狗的独白

    我是一条资深画图狗…… 毫不夸张的说,到了画图周忙的昏天黑地,吃饭喝水睡觉都会忘记……只有画图画图画图,模型模型模...

  • 画图

    周五早会技术员通知,下周一每人交岗位练兵记录本。 从五月初就下发通知,每人每周练兵五道题并画一张岗位工艺流程图。但...

网友评论

      本文标题:画图i

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