Giter Club home page Giter Club logo

rsbarcodes_swift's Introduction

RSBarcodes, now Swift.

Total views Views in the last 24 hours

RSBarcodes allows you to read 1D and 2D barcodes using metadata scanning capabilities introduced with iOS 7 and generate the same set of barcode images for displaying and sharing. Now Swift.

##TODO

###Generators

  • Code39
  • Code39Mod43
  • ExtendedCode39
  • Code93
  • Code128
  • UPCE
  • EAN FAMILIY (EAN8 EAN13 ISBN13 ISSN13)
  • ITF14
  • Interleaved2of5
  • DataMatrix
  • PDF417
  • QR
  • Aztec
  • Views

###Reader

  • Views
  • ReaderController

##Installation

  1. Add RSBarcodes_Swift as a submodule by opening the Terminal, cd-ing into your top-level project directory, and entering the command git submodule add https://github.com/yeahdongcn/RSBarcodes_Swift.git
  2. Open the RSBarcodes_Swift folder, and drag RSBarcodes.xcodeproj into the file navigator of your app project.
  3. In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
  4. Ensure that the deployment target of RSBarcodes.framework matches that of the application target.
  5. In the tab bar at the top of that window, open the "Build Phases" panel.
  6. Expand the "Target Dependencies" group, and add RSBarcodes.framework.
  7. Click on the + button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add RSBarcodes.framework.

##Usage

###Generators

The simplest way to use the generators is:

RSUnifiedCodeGenerator.shared.generateCode("2166529V", machineReadableCodeObjectType: AVMetadataObjectTypeCode39Code)

It will generate an UIImage instance if the 2166529V is a valid code39 string. For AVMetadataObjectTypeCode128Code, you can change useBuiltInCode128Generator to false to use my implementation (AutoTable for code128).

P.S. There are 4 table for encoding a string to code128, TableA, TableB, TableC and TableAuto, the TableAuto is always the best choice, but if one has certain requirement, try this:

RSCode128Generator(codeTable: .A).generateCode("123456", machineReadableCodeObjectType: AVMetadataObjectTypeCode128Code)

These calling simples can be found in the test project.

###Reader

Place an UIViewController in storyboard and set RSCodeReaderViewController based class as its custom class and it almost there, focus mark layer and corners layer is already there working for you. There are to handlers, one for the single tap on the screen along with the focus mark and the other is detected objects handler, which all detected will come to you. Set them up in viewDidLoad() or some place more suitable:

override func viewDidLoad() {
    super.viewDidLoad()
    
    self.focusMarkLayer.strokeColor = UIColor.redColor().CGColor
    
    self.cornersLayer.strokeColor = UIColor.yellowColor().CGColor
    
    self.tapHandler = { point in
        println(point)
    }
    
    self.barcodesHandler = { barcodes in
        for barcode in barcodes {
            println(barcode)
        }
    }
}

If you want to ignore some code types, you'd better add following lines

let types = NSMutableArray(array: self.output.availableMetadataObjectTypes)
types.removeObject(AVMetadataObjectTypeQRCode)
self.output.metadataObjectTypes = NSArray(array: types)

###Helper

Try RSAbstractCodeGenerator.resizeImage(<#source: UIImage#>, scale: <#CGFloat#>) to scale the generated image.

##Miscellaneous

The Swift Programming Language 中文版

Online version generated using GitBook

##License

The MIT License (MIT)

Copyright (c) 2012-2014 P.D.Q.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

rsbarcodes_swift's People

Contributors

yeahdongcn avatar

Watchers

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