zoukankan      html  css  js  c++  java
  • 文字绘制-图片绘制-水印绘制思路

     1     override func draw(_ rect: CGRect) {
     2         
     3         // 文字绘制 - 可以做文字水印
     4         let str = "打脸啊" as NSString
     5         
     6         let attDict:[String:Any] = [NSFontAttributeName:UIFont.systemFont(ofSize: 16),
     7                                     NSForegroundColorAttributeName:UIColor.red]
     8         
     9         let point = CGPoint(x: 20, y: 20)
    10         // str.draw(in: <#T##CGRect#>, withAttributes: <#T##[String : Any]?#>)
    11         str.draw(at: point, withAttributes: attDict)
    12         
    13         
    14         // 图片绘制 - 可以做图片水印
    15         let img = UIImage(named: "logo")!
    16         // img.draw(at: <#T##CGPoint#>)
    17         //img.draw(in: <#T##CGRect#>)
    18         // 以平铺方式绘制图片,大小跟图片的真实大小一样
    19         img.drawAsPattern(in: <#T##CGRect#>)
    20         
    21         // 而且:iOS7.0之后,UIView具有以下方法,各种控件都可以加到水印上
    22         // func drawHierarchy(in rect: CGRect, afterScreenUpdates afterUpdates: Bool) -> Bool
    23         
    24     }
  • 相关阅读:
    git分支合并
    php错误处理
    php面试全套
    php面试的那些“黑话”
    快速在命令窗口打开当前路径
    @Autowired注解的使用方法
    jsp页面获取表单的值
    jsp打印九九乘法表
    Google hack
    java中的集合collection
  • 原文地址:https://www.cnblogs.com/panda1024/p/6253036.html
Copyright © 2011-2022 走看看