How to create QR code with custom logo and color.

Tram Ho

QR Code is used a lot to share content or add new users in apps like Twitter and Snapchat.

Since iOS 11, users can scan QR codes with the camera.

This makes integrating QR codes in your own apps even nicer.

QR code generation in iOS

QR code generation in iOS is easier than ever since Core Image CIQRCodeGenerator filter. It generates a black and white QR for an input string string.

This QR code might work, but it’s not as appealing yet, and maybe you want it to look better.

Hence, I will show you how to customize it to fit my application design.

Change the color of the QR code

The first step in customizing the QR code is to change the colors. We do this in three steps:

  • Invert the black and white
  • Cover black to transparent
  • Change color

To make this code easier to use, we create an extension of CIImage .

QR codes usually link to a URL. Therefore, you should also create an extension for the URL.

And use it as follows:

The QR code has changed color:

Custom logo for QR code

To make it a truly outstanding QR code, we can add our own custom logo. QR codes allow us to replace a certain part of it with a custom logo. To do this, we create another CIImage extension, use the logo, and return a new CIImage.

Combined with the newly updated URL extension, we can create a more beautiful new QR code including custom logo.

Achievement:

Hope it is useful to you, thank you for watching all the articles!

Source: medium.com

Share the news now

Source : Viblo