Coder Social home page Coder Social logo

swiftscan's Introduction

Swift Carthage Compatible Platform

SwiftScan

主要内容的介绍

  • 生成二维码/条形码

  • 扫描二维码/条形码

  • 根据光线强弱开启手电筒

  • 扫描成功之后界面之间逻辑跳转处理

  • 扫描界面可自定义(线扫描条样式以及网格样式)

  • 扫描界面仿微信、支付宝(请根据项目需求,自行布局或调整)

Requirements

  • Swift 4.2
  • iOS 9.0.0+
  • Xcode 9.x

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

To integrate SwiftScan into your Xcode project using Carthage, specify it in your Cartfile:

github "chenjie1219/SwiftScan"

Run carthage update to build the framework and drag the built SwiftScanner.framework into your Xcode project.

Manually

Just download the project, and drag and drop the "SwiftScanner" folder in your project.


Usage

1、在 info.plist 中添加以下字段(iOS 10 之后需添加的字段)

  • NSCameraUsageDescription (相机权限访问)

2、二维码扫描

Push方式弹出扫描页面
/// 创建二维码扫描
let vc = ScannerVC() 

//设置标题、颜色、扫描样式(线条、网格)、提示文字
vc.setupScanner("微信扫一扫", .green, .default, "将二维码/条码放入框内,即可自动扫描") { (code) in
//扫描回调方法
<#code#>

//关闭扫描页面
self.navigationController?.popViewController(animated: true)
}

//push到扫描页面
navigationController?.pushViewController(vc, animated: true)
Present方式弹出扫描页面
/// 创建二维码扫描
let vc = ScannerVC() 

//设置标题、颜色、扫描样式(线条、网格)、提示文字
vc.setupScanner("支付宝扫一扫", .blue, .grid, "放入框内,自动扫描") { (code) in
//扫描回调方法
<#code#>

//关闭扫描页面
self.dismiss(animated: true, completion: nil)
}

//Present到扫描页面
present(vc, animated: true, completion: nil)

3、二维码生成

/// 带 logo 的二维码(logoImage为nil则不带logo)
QRCodeView.image = UIImage.generateQRCode("https://github.com/chenjie1219", 300, logoImage, .orange)

4、条形码生成

/// 条形码
barCodeView.image = UIImage.generateCode128("https://github.com/chenjie1219", CGSize(width: 300, height: 100, .blue)

效果图

1 2 3 4 5 6 7 8

Author

swiftscan's People

Contributors

chenjie1219 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.