• 文字绘制-图片绘制-水印绘制思路


     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     }
  • 相关阅读:
    2016.7.17
    2016.7.16
    2016.7.15
    2016.7.12
    2016.7.11
    2016.7.10
    coco2d-x中的坐标系问题
    cocos2d-x中的Tiled地图
    cocos2d-x中的Box2D物理引擎
    python文件处理及装饰器
  • 原文地址:https://www.cnblogs.com/panda1024/p/6253036.html
Copyright © 2020-2023  润新知