Giter Site home page Giter Site logo

haaakon / qrscanner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mercari/qrscanner

0.0 1.0 0.0 11.65 MB

A simple QR Code scanner framework for iOS. Provides a similar scan effect to ios13.

License: MIT License

Ruby 2.44% Objective-C 1.90% Swift 95.66%

qrscanner's Introduction

QRScanner

A simple QR Code scanner framework for iOS. Provides a similar scan effect to ios13+. Written in Swift.

iOS 13.0+ Use QRScanner in iOS 10.0+

"QR Code" is a registered trademark of DENSO WAVE INCORPORATED

Feature

  • Similar to iOS 13.0+ design
  • Simple usage Sample
  • Support for iOS 10.0+

Development Requirements

  • iOS 10.0+
  • Swift: 5.0
  • XCode Version: 10.3 (10G8)

Installation

CocoaPods is the recommended method of installing QRScanner.

The Pod Way

  • Simply add the following line to your Podfile
  platform :ios, '10.0'
  pod 'MercariQRScanner'
  • Run command
  pod install
  • Write Import statement on your source file
  import MercariQRScanner

The Carthage Way

  • Move your project dir and create Cartfile
> touch Cartfile
  • add the following line to Cartfile
github "mercari/QRScanner"
  • Create framework
> carthage update --platform iOS
  • In Xcode, move to "Genera > Build Phase > Linked Frameworks and Library"
  • Add the framework to your project
  • Add a new run script and put the following code
/usr/local/bin/carthage copy-frameworks
  • Click "+" at Input file and Add the framework path
$(SRCROOT)/Carthage/Build/iOS/QRScanner.framework
  • Write Import statement on your source file
import QRScanner

Usage

See QRScannerSample

Add Privacy - Camera Usage Description to Info.plist file

The Basis Of Usage

import QRScanner
// If use the Pod way, please import MercariQRScanner

final class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        let qrScannerView = QRScannerView(frame: view.bounds)
        view.addSubview(qrScannerView)
        qrScannerView.configure(delegate: self)
        qrScannerView.startRunning()
    }
}

extension ViewController: QRScannerViewDelegate {
    func qrScannerView(_ qrScannerView: QRScannerView, didFailure error: QRScannerError) {
        print(error)
    }

    func qrScannerView(_ qrScannerView: QRScannerView, didSuccess code: String) {
        print(code)
    }
}

Customization

Source Code Way

override func viewDidLoad() {
        super.viewDidLoad()

        let qrScannerView = QRScannerView(frame: view.bounds)

        // Customize focusImage, focusImagePadding, animationDuration
        qrScannerView.focusImage = UIImage(named: "scan_qr_focus")
        qrScannerView.focusImagePadding = 8.0
        qrScannerView.animationDuration = 0.5

        qrScannerView.configure(delegate: self)
        view.addSubview(qrScannerView)
        qrScannerView.startRunning()
}

Interface Builder Way

Setup Custom Class Customize

Add FlashButton

FlashButtonSample

final class ViewController: UIViewController {

    ...

    @IBOutlet var flashButton: FlashButton!

    @IBAction func tapFlashButton(_ sender: UIButton) {
        qrScannerView.setTorchActive(isOn: !sender.isSelected)
    }
}

extension ViewController: QRScannerViewDelegate {

    ...

    func qrScannerView(_ qrScannerView: QRScannerView, didChangeTorchActive isOn: Bool) {
        flashButton.isSelected = isOn
    }
}

Add Blur Effect

Source Code Way

     qrScannerView.configure(delegate: self, input: .init(isBlurEffectEnabled: true))

Interface Builder Way

Customize

Committers

Contribution

Please read the CLA carefully before submitting your contribution to Mercari. Under any circumstances, by submitting your contribution, you are deemed to accept and agree to be bound by the terms and conditions of the CLA.

https://www.mercari.com/cla/

License

Copyright 2019 Mercari, Inc.

Licensed under the MIT License.

qrscanner's People

Contributors

hitsubunnu avatar daichiro avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.