Custom rounded QR code with lots of customization.

Overview

RoundCode for iOS

License Swift 5 Twitter: @aslanyanhaik

RoundCode is custom circular QR code with lots of customization. Similar to Facebook messenger and Apple's App Clip Codes the RoundCode includes convenient camera scanner and decoder.

Different styles of RoundCode for iOS

Installation

Cocoapods:

pod 'RoundCode'

Swift Package Manager:

File > Swift Packages > Add Package Dependency

https://github.com/aslanyanhaik/RoundCode

Usage example

import framework

import RoundCode

Encoding

create coder and encode

let image = RCImage(message: "Hello World")
let coder = RCCoder()
do {
  imageView.image = try coder.encode(image)
} catch {
  //handle errors
}

You can also validate the messsage before encoding

let coder = RCCoder()
let isValidText = coder.validate("Hello world")

Decoding

Create instane of RCCameraViewController and handle the delegate

class ViewController: UIViewController, RCCameraViewControllerDelegate {
  
  func scan() {
    let cameraController = RCCameraViewController()
    cameraController.delegate = self
    present(cameraController, animated: true)
  }
  
  func cameraViewController(didFinishScanning message: String) {
    messageLabel.text = message
  }
}

You can also decode a UIImage like this

let coder = RCCoder()
do {
  messageLabel.text = try coder.decode(UIImage(named: code)!)
} catch {
  //handle errors
}

Appearance

You can change the appearance like this

var image = RCImage(message: "Hello world")
image.contentInsets = UIEdgeInsets(top: 8, left: 10, bottom: 4, right: 10)
image.attachmentImage = UIImage(named: "Profile")
image.size = 300
image.gradientType = .linear(angle: CGFloat.pi)
image.tintColors = [.red, .black]

If image is on dark background you should change scanning mode to darkBackground

let coder = RCCoder()
coder.scanningMode = .darkBackground

Advanced coding configuration

You can provide custom coding configuration in order to encode long text by reducing number of characters

let configuration = RCCoderConfiguration.shortConfiguration
let coder = RCCoder(configuration: configuration)
let configuration = RCCoderConfiguration(characters: " -abcdefghijklmnopqrstuvwxyz0123456789")
let coder = RCCoder(configuration: configuration)

⚠️ If you are encoding with custom configuration, then you should change the RCCameraViewController configuration ⚠️

let configuration = RCCoderConfiguration(characters: " -abcdefghijklmnopqrstuvwxyz0123456789")
let coder = RCCoder(configuration: configuration)
let camera = RCCameraViewController()
camera.coder = coder

Compatibility

Written in Swift 5 and requires Xcode 11.0

RoundCode is compatible with iOS 13.0+.

Screenshot of RoundCode for iOS

Author

License

Copyright 2020 Haik Aslanyan.

Licensed under MIT License: https://opensource.org/licenses/MIT

Comments
  • Decode not working from camera roll

    Decode not working from camera roll

    Love the package. Great work. I'm not able to get it working with codes generated by the package that are then loaded from my camera roll. I tested the example project in the repo which also failed with a generic decode error.

    if let message = try? coder.decode(camImage) {
      messageLabel.text = message
      messageLabel.isHidden = false
      DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
        self.messageLabel.isHidden = true
      }
    }
    
    enhancement 
    opened by maxmzd 7
  • Android Clone

    Android Clone

    Hi, Do you know if one Android repo exists, like a clone of your project ?

    I want to use your code for one project, but i need to have the same with the android app, only to read it

    Thanks

    opened by ljs19923 4
  • Impressive! Some suggestion how to improve

    Impressive! Some suggestion how to improve

    I never thought that something that possible to do in Swift. Well done! 👍

    Here some ideas to improve performance of your algo:

    1. The slowest part of your algo it control point detector. If you will use simplest structure here, you will have better performance and it will be possible to process full image.
      static let lightBackgroundRange = UInt8(0)...UInt8(180) // simple compare better: pixel < 180 
      static let darkBackgroundRange = UInt8(100)...UInt8(255) // simple compare better: pixel > 100 
    

    I recommend to perform threshold separately. Accelerate framework can help


    let bit = pixelThreshold.contains(data[x, y]) ? RCBit.one : RCBit.zero
    

    You probably don't need RCBit abstraction. typealias around bool will works better and pretty informative


    pixelPatterns[pixelPatterns.count - 1] = lastPattern
    

    This operation call lot of times. Just with change struct to class and you can remove this line


    2) Reed Solomon codes. Additional you will get error restoration. You have interesting idea with something like `hash` with `RCMatrix` (if I understand it right). To make orientation working, you can try 4 possible orientation on decode bits. It's stupid and simple solution.

    You awesome! =)

    opened by AlexandrGraschenkov 4
  • Increase number of accepted characters in textfield input

    Increase number of accepted characters in textfield input

    Hey,

    I would like to know if it possible to increase the number of input characters in the textfield where you put your string with the default configuration. I want to pass firebase UID but I can because they are too long.

    Thanks.

    opened by EdwinJr13 4
  • Does the detection have to be on a white BG?

    Does the detection have to be on a white BG?

    Seems like it only works on the output generated image (White Background), not while on a black BG (using the example app). Could this be made configurable?

    I tried to apply a CIFilter(name: "CIColorInvert") to the pixelBuffer with not much luck.

    enhancement 
    opened by naturalui 4
  • Limitation

    Limitation

    Hi!

    I know that it isn't issue per se but I have a question directly connected with the code encoder/decoder. May I ask for some data about limitation (especially in terms of character amount) and the "regen" level for damaged codes?

    opened by Rudzix77 0
  • darkBackground not working for iOS 14

    darkBackground not working for iOS 14

    I am trying to decode a Round code with a white tint and black background and an image in the middle. I am running on iOS 14 . Regardless of what scanning mode I put It on, It only works for a dark Roundcode on a white background.

    opened by samuelail 0
  • coder.scanningMode = .darkBackground not working for iOS 14

    coder.scanningMode = .darkBackground not working for iOS 14

    I am trying to decode a Round code with a white tint and black background and an image in the middle. I am running on iOS 14 . Regardless of what scanning mode I put It on, It only works for a dark Roundcode on a white background.

    opened by samuelail 0
  • coder.scanningMode = .darkBackground not working for iOS 14

    coder.scanningMode = .darkBackground not working for iOS 14

    I am trying to decode a Round code with a white tint and black background and an image in the middle. I am running on iOS 14 . Regardless of what scanning mode I put It on, It only works for a dark Roundcode on a white background.

    opened by samuelail 0
  • Why is RoundCodes only compatible with iOS 13.0+?

    Why is RoundCodes only compatible with iOS 13.0+?

    The README states that RoundCodes is written in Swift 5, requires Xcode 11 and is compatible with iOS 13.0+. Does it not work below iOS 13? Which APIs do you use that are not available on, say, iOS 11?

    enhancement 
    opened by mrousavy 1
Releases(1.3.0)
Owner
Henry Aslanyan
iOS biped, computer forensics dabbler. I turn coffee into code...
Henry Aslanyan
QR Blank - QR Code URL scanner

QR Blank - QR Code URL scanner No Ads, Clean, Simple open source QR Code URL scanner Check URL by Google Safe Browsing before open. Google Safe Browsi

Johnson Kaho Poon 37 Feb 7, 2022
A QR Code Scanning Framework For IOS

QRReader A QR Code Scanning Framework For IOS Requirements: IOS 11+ Xcode: 12+ Installation: steps to install this framework in your xcode project Pod

Frameworks 7 Nov 23, 2022
ZATCA (Fatoora) QR-Code Implementation in iOS

An unofficial package to help iOS developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing in iOS Apps on smart phones and POS devices.

jawad 5 Feb 21, 2022
A simple Safari web extension that displays a QR code for the webpage in focus.

QR Pop ?? QR Pop is a simple iOS & MacOS app and Safari extension built to make displaying QR codes easy. The Safari Extension is inspired by the quic

Shawn 9 Dec 11, 2022
Simple application for creating QR code with a background

BeautifyQR Импортирует исходный QR-код из галереи Накладывает его на выбранную картинку с фоном Полученную картинку можно вынести виджетом на домашний

Dmitry Demianov 1 Nov 28, 2021
A better way to operate QR Code in Swift, support iOS, macOS, watchOS and tvOS.

EFQRCode is a lightweight, pure-Swift library for generating stylized QRCode images with watermark or icon, and for recognizing QRCode from images, in

EFPrefix 4.3k Dec 29, 2022
QR code detector. Simple usage, you can get recognition results via delegate or callback.

SPQRCode QR code detector. Simple usage, you can get recognition results via delegate or callback. Installation Swift Package Manager CocoaPods Manual

Sparrow Code 58 Jan 6, 2023
A Simple iOS QR code scanner that allows users to enable their camera and local Photo Library accesses to scan the contents of the input QR codes.

iOS QR Code Scanner A Simple iOS QR code scanner using Swift UI. Jump to: ContentView.swift screenshot 1.1.5 NOTE: be aware of the new horizontal line

Krystal Zhang 0 Jan 1, 2023
Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less.

▤ SideMenu If you like SideMenu, give it a ★ at the top right of this page. SideMenu needs your help! If you're a skilled iOS developer and want to he

Jon Kent 5.4k Dec 29, 2022
🚗 iOS app for finding public parking lots

?? ParkenDD ParkenDD shows you the current parking situation for various European cities, including Dresden, Ingolstadt, Hamburg, Zürich and Aarhus to

Kilian Koeltzsch 49 Feb 9, 2022
Converts Markdown files and strings into NSAttributedStrings with lots of customisation options.

SwiftyMarkdown 1.0 SwiftyMarkdown converts Markdown files and strings into NSAttributedStrings using sensible defaults and a Swift-style syntax. It us

Simon Fairbairn 1.5k Dec 22, 2022
Rounded async imageview downloader lightly cached and written in Swift

PASImageView ============ **Rounded async imageview downloader lightly cached and written in Swift 3 ** Objective-C version here Snapshot Usage //XIB

Pierre Abi-aad 173 Nov 6, 2022
A flexible container view featuring a solid background with rounded corners.

A flexible container view featuring a solid background with rounded corners.

Tim Oliver 13 Jan 22, 2022
iOS Swift class to create circular or rounded avatar images

SwiftyAvatar iOS Swift 3.0 UIimage class Create awesome circular avatar images! IBInspectable attributes accessible from the identity inspector. Round

Dimitrios Kalaitzidis 183 Dec 17, 2022
A high-performance button control with rounded corners for iOS.

TORoundedButton TORoundedButton is an open source UI control of a standard user button. Its design consists of displaying text on top of a solid recta

Tim Oliver 480 Dec 26, 2022
AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.

AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.

Abdelrhman Kamal 79 Jan 3, 2023
SwiftBar - Powerful macOS menu bar customization tool

SwiftBar - Powerful macOS menu bar customization tool

SwiftBar 2k Jan 8, 2023
Intuitive cycling tracker app for iOS built with SwiftUI using Xcode. Features live route tracking, live metrics, storage of past cycling routes and many customization settings.

GoCycling Available on the iOS App Store https://apps.apple.com/app/go-cycling/id1565861313 App Icon About Go Cycling is a cycling tracker app built e

Anthony Hopkins 64 Dec 19, 2022
Light wrapper of UIButton that allows extra customization for tvOS

FocusTvButton Light wrapper of UIButton that allows extra customization for tvOS If you would like to have the same level of customization in tablevie

David Cordero 68 Nov 12, 2022
Light wrapper of UITableViewCell that allows extra customization for tvOS

TvOSCustomizableTableViewCell Light wrapper of UITableViewCell that allows extra customization for tvOS If you would like to have the same level of cu

Zattoo 31 Nov 9, 2022