欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

绘制斜体文字

程序员文章站 2022-11-02 08:14:03
使用注入js的方式添加水印 需要获取网页的高度,如果 打开的是PDF 等文件,水印会添加失败,可以在webview前添加一层view 绘制水印,缺点是不能随webview 上下滑动override func draw(_ rect: CGRect) { guard let ctx:CGContext = UIGraphicsGetCurrentContext() else { return } ctx.concatenate(CGAffineTrans......

绘制斜体文字

 

使用注入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

相关标签: swift