title: How can I change the color of my QR Code
body: <p>I'm working in an app that should contain a QR code with info, I know how to do that, but I have to set the color of the Qrcode from black to red and I as I understand it should be easy, but I can't find a good answer to make this possible, I'll let my code and my screen of the QrCode, thanks. </p>
  
  <pre><code>import UIKit
  
  class QRCodeViewController: UIViewController {
      @IBOutlet weak var imgQRCode: UIImageView!
  
      func generateQRCode(from string: String) -&gt; UIImage? {
          let data = string.data(using: String.Encoding.utf8)
          if let filter = CIFilter(name: "CIQRCodeGenerator") {
              filter.setValue(data, forKey: "inputMessage")
              filter.setValue("H", forKey: "inputCorrectionLevel")
  
              guard let qrCodeImage = filter.outputImage
                  else {
                      return nil
              }
              let scaleX = imgQRCode.frame.size.width / qrCodeImage.extent.size.width
              let scaleY = imgQRCode.frame.size.height / qrCodeImage.extent.size.height
              let transform = CGAffineTransform(scaleX: scaleX, y: scaleY)
  
                  if let output = filter.outputImage?.applying(transform) {
                      return UIImage(ciImage: output)
                  }
              }
              return nil
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          let image = generateQRCode(from: "Este es el código generado")
          imgQRCode.image = image
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/6bk1d.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/6bk1d.jpg" alt="QRCODE"></a></p>