Code Monkey home page Code Monkey logo

lbxscan's Introduction

iOS 二维码、条形码

Platform Language License CocoaPods Version

swift版本 点这里

DIY参数理解参考工具点这里

QQ交流群: 522806629

iOS扫码封装

  • 扫码识别封装: 系统API(AVFoundation)、ZXing、ZBar
  • 扫码界面效果封装
  • 二维码、条形码
  • 相册获取图片后识别

设置参数自定义效果

  • 扫码框周围区域背景色可设置
  • 扫码框颜色可也设置
  • 扫码框4个角的颜色可设置、大小可设置
  • 可设置只识别扫码框内的图像区域
  • 可设置扫码成功后,获取当前图片
  • 动画效果选择: 线条上下移动、网格形式移动、中间线条不移动(一般扫码条形码的效果)

模仿其他app(通过设置参数即可完成)

  • 模仿QQ扫码界面
  • 支付宝扫码框效果
  • 微信扫码框效果

历史版本

2.3

  • 修改ZXing内存修改bug,完善ZXing扫码完成后,内存释放
  • Demo相机和相册权限获取代码优化
  • ZBar修改参数支持ITF-14
  • 扫码启动相机提示优化,放置中间位置

2.2

  • 可分库下载(native、ZXing、ZBar)

1.x

  • 1.x

Installation with CocoaPods

可独立安装某一功能,ZXing已经下载到本工程,解决之前版本下载速度慢的问题


  • 安装所有库包括UI
 pod 'LBXScan', '~> 2.3'

建议按下面这样分组写,安装好后按文件夹分组,否则所有文件在一个文件夹里,很乱

pod 'LBXScan/LBXNative','~> 2.3'
pod 'LBXScan/LBXZXing','~> 2.3'
pod 'LBXScan/LBXZBar','~> 2.3'
pod 'LBXScan/UI','~> 2.3'
  • 只安装系统原生API封装库
pod 'LBXScan/LBXNative','~> 2.3'
  • 只安装ZXing封装库
pod 'LBXScan/LBXZXing','~> 2.3'
  • 只安装ZBar封装库
pod 'LBXScan/LBXZBar','~> 2.3'
  • 只安装UI
pod 'LBXScan/UI','~> 2.3'
  • 安装任意组合

你可以通过上面的安装方式,安装任意组合

Demo测试

  • xcode版本:xcode9.2
  • 将工程下载下来,打开DemoTests中 LBXScanDemo.xcworkspace
  • Demo提供了选择对应库进行扫码识别、相册选择图片识别、生成条码等测试

UI DIY参数介绍

辅助理解参考工具请看:LBXScanUITool

- (LBXScanViewStyle*)DIY
{
//设置扫码区域参数
LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];

//扫码框中心位置与View中心位置上移偏移像素(一般扫码框在视图中心位置上方一点)
style.centerUpOffset = 44;



//扫码框周围4个角的类型设置为在框的上面,可自行修改查看效果
style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_On;

//扫码框周围4个角绘制线段宽度
style.photoframeLineW = 6;

//扫码框周围4个角水平长度
style.photoframeAngleW = 24;

//扫码框周围4个角垂直高度
style.photoframeAngleH = 24;


//动画类型:网格形式,模仿支付宝
style.anmiationStyle = LBXScanViewAnimationStyle_NetGrid;

//动画图片:网格图片
style.animationImage = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_part_net"];;

//扫码框周围4个角的颜色
style.colorAngle = [UIColor colorWithRed:65./255. green:174./255. blue:57./255. alpha:1.0];

//是否显示扫码框
style.isNeedShowRetangle = YES;
//扫码框颜色
style.colorRetangleLine = [UIColor colorWithRed:247/255. green:202./255. blue:15./255. alpha:1.0];

//非扫码框区域颜色(扫码框周围颜色,一般颜色略暗)
//必须通过[UIColor colorWithRed: green: blue: alpha:]来创建,内部需要解析成RGBA
style.notRecoginitonArea = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];

return style;
}

使用扫码控制器LBXScanViewController

如果你需要使用提供的扫码控制器LBXScanViewController(包含在UI模块中),需要在你的工程中添加预编译头文件xx.pch文件或对应调用的地方添加对应的宏(LBXScanViewController代码包含了所有的库和UI,所以需要你根据你自己下载的库的情况,对应添加宏)

例如,当前工程Demo中PrefixHeader.pch,我的demo中下载了所有的模块,所以下面定义了各个模块的宏


#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#define LBXScan_Define_Native  //下载了native模块
#define LBXScan_Define_ZXing   //下载了ZXing模块
#define LBXScan_Define_ZBar   //下载了ZBar模块
#define LBXScan_Define_UI     //下载了界面模块
#endif

扫码结果处理,可以通过实现委托方法 scanResultWithArray 或继承控制器LBXScanViewController,然后override方法scanResultWithArray即可

界面效果

image

lbxscan's People

Contributors

mxabc avatar xxjh avatar maxfong avatar scottphc avatar longlz19 avatar zxldev 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.