标签:generate string lex transform mes form nal 大小 nsf
1 // 生成二维码 2 final class QRGenerator { 3 static func generate(from string: String) -> UIImage? { 4 let context = CIContext() 5 // let data = string.data(using: String.Encoding.ascii) 6 let data = string.data(using: String.Encoding.utf8) 7 8 if let filter = CIFilter(name: "CIQRCodeGenerator") { 9 filter.setValue(data, forKey: "inputMessage") 10 let transform = CGAffineTransform(scaleX: 7, y: 7) 11 if let output = filter.outputImage?.transformed(by: transform), let cgImage = context.createCGImage(output, from: output.extent) { 12 return UIImage(cgImage: cgImage) 13 } 14 } 15 return nil 16 } 17 }
ASCII编码:最早只有127个字母被编码到计算机里,也就是大小写英文字母、数字和一些符号,这个编码表被称为ASCII
编码。
.ascii仅支持英文,.utf8支持中英文
标签:generate string lex transform mes form nal 大小 nsf
原文地址:https://www.cnblogs.com/madarax/p/9702369.html