绘制斜体文字

2022-07-30,,

 

使用注入js的方式添加水印 需要获取网页的高度,如果 打开的是PDF 等文件,水印会添加失败,可以在webview前添加一层view 绘制水印,缺点是不能随webview 上下滑动

 

override func draw(_ rect: CGRect) {

        guard let ctx:CGContext = UIGraphicsGetCurrentContext() else { return }

        ctx.concatenate(CGAffineTransform(rotationAngle: CGFloat(-Double.pi / 4.0)))

        for i in 0..<self.num{

            for j in 0..<self.num{

                let str:NSString = self.text! as NSString

                str.draw(at: CGPoint(x: self.frame.size.width-CGFloat(200*i), y: CGFloat(200*j)), withAttributes: [NSAttributedString.Key.font:UIFont.systemFont(ofSize: UIFont.systemFontSize),NSAttributedString.Key.foregroundColor:UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.2)])

            }

        }

        ctx.concatenate(CGAffineTransform(rotationAngle: CGFloat(Double.pi / 4.0)))

    }

本文地址:https://blog.csdn.net/flg1554112450/article/details/107933176

《绘制斜体文字.doc》

下载本文的Word格式文档,以方便收藏与打印。