返回排行榜

EFPrefix/EFQRCode

Swiftefprefix.github.io/EFQRCode

A better way to operate QRCode in Swift, support iOS, macOS, watchOS, tvOS, and/or visionOS.

swiftiosqrcodebarcodebarcode-scannerbarcode-generatorbarcodesqrcode-generatorqrcode-scannerqrcode-readerqrcodesgenerator
Star 增长趋势
Star
4.8k
Forks
504
周增长
Issues
5
2k4k
2017年1月2020年3月2023年5月2026年7月
README

EFQRCode is a lightweight, pure-Swift library for generating stylized QRCode images with watermark or icon, and for recognizing QRCode from images, inspired by qrcode and react-qrbtf. Based on CoreGraphics, CoreImage, and ImageIO, EFQRCode provides you a better way to handle QRCode in your app, no matter if it is on iOS, macOS, watchOS, tvOS, and/or visionOS. You can integrate EFQRCode through CocoaPods, Carthage, and/or Swift Package Manager.

Examples

Demo Projects

App Store

You can click the App Store button below to download demo, support iOS, tvOS and watchOS:

You can also click the Mac App Store button below to download demo for macOS:

Compile Demo Manually

To run the example project manually, clone the repo, demos are in the 'Examples' folder, then open EFQRCode.xcworkspace with Xcode and select the target you want, run.

Or you can run the following command in terminal:

git clone git@github.com:EFPrefix/EFQRCode.git; cd EFQRCode; open 'EFQRCode.xcworkspace'

Requirements

iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ / visionOS 1.0+

Installation

CocoaPods

EFQRCode is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'EFQRCode', '~> 7.0.3'

Then, run the following command:

$ pod install

Carthage

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

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

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

github "EFPrefix/EFQRCode" ~> 7.0.3

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

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the Swift compiler.

Once you have your Swift package set up, adding EFQRCode as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/EFPrefix/EFQRCode.git", .upToNextMinor(from: "7.0.3"))
]

Quick Start

1. Import EFQRCode

Import EFQRCode module where you want to use it:

import EFQRCode

2. Recognition

A String Array is returned as there might be several QR Codes in a single CGImage:

if let testImage = UIImage(named: "test.png")?.cgImage {
    let codes = EFQRCode.Recognizer(image: testImage).recognize()
    if !codes.isEmpty {
        print("There are \(codes.count) codes")
        for (index, code) in codes.enumerated() {
            print("The content of QR Code \(index) is \(code).")
        }
    } else {
        print("There is no QR Codes in testImage.")
    }
}

3. Generation

3.1 Create QR Code with static image
let generator = try? EFQRCode.Generator("https://github.com/EFPrefix/EFQRCode", style: .image(
    params: .init(image: .init(image: .static(image: UIImage(named: "WWF")?.cgImage!), allowTransparent: true)))
)
if let image = try? generator?.toImage(width: 180).cgImage {
    print("Create QRCode image success \(image)")
} else {
    print("Create QRCode image failed!")
}

Result:

3.2 Generation from animated images

You can create a dynamic QR code by passing in a sequence of animated images. The usage method is as follows:

let generator = try? EFQRCode.Generator("https://github.com/EFPrefix/EFQRCode", style: .image(
    params: .init(image: .init(image: .animated(images: cgImages, imageDelays: cgImageDelays))))
)
if let imageData = try? generator?.toGIFData(width: 512) {
    print("Create QRCode image success \(imageData)")
} else {
    print("Create QRCode image failed!")
}

You can get more information from the demo, result will like this:

3.3 Exportable types
  • Static: NSImage, UIImage, PDF, PNG, JPEG
  • Animated: APNG, GIF, SVG, MOV, MP4, M4V

4. Next

Learn more from DeepWiki.

Recommendations

  1. Please select a high contrast foreground and background color combinations;
  2. To improve the definition of QRCode images, increase size;
  3. Oversized generation dimensions, excessive QR code content, and overly large imported media may lead to generation failures;
  4. It is recommended to test the QRCode image before put it into use;
  5. Any contributing and pull requests are warmly welcome;
  6. Part of the pictures in the demo project and guide come from the internet. If there is any infringement of your legitimate rights and interests, please contact us to delete.

Contributors

Backers

Sponsors

Contact

Twitter: @EyreFree777
Weibo: @EyreFree
Email: eyrefree@eyrefree.org

License

EFQRCode is available under the MIT license. See the LICENSE file for more info.

相关仓库
justjavac/free-programming-books-zh_CN

:books: 免费的计算机编程类中文书籍,欢迎投稿

GNU General Public License v3.0pythonjavascript
weibo.com/justjavac
117.7k28.2k
appwrite/appwrite

Appwrite® - complete cloud infrastructure for your web, mobile and AI apps. Including Auth, Databases, Storage, Functions, Messaging, Hosting, Realtime and more

TypeScriptnpmBSD 3-Clause "New" or "Revised" Licenseappwritedocker
appwrite.io
56.6k5.6k
dkhamsing/open-source-ios-apps

:iphone: Collaborative List of Open-Source iOS Apps

Creative Commons Zero v1.0 Universaliosswift
51.3k6k
serhii-londar/open-source-mac-os-apps

🚀 Awesome list of open source applications for macOS. https://t.me/s/opensourcemacosapps

Creative Commons Zero v1.0 Universalmacosmac
49.7k2.6k
iina/iina

The modern video player for macOS.

SwiftGNU General Public License v3.0macosvideo-player
iina.io
45.7k2.9k
Alamofire/Alamofire

Elegant HTTP Networking in Swift

SwiftMIT Licensenetworkingurlsession
42.4k7.7k
xitu/gold-miner

🥇掘金翻译计划,可能是世界最大最好的英译中技术社区,最懂读者和译者的翻译平台:

androidtranslation
juejin.cn/tag/%E6%8E%98%E9%87%91%E7%BF%BB%E8%AF%91%E8%AE%A1%E5%88%92
34.3k5k
MonitorControl/MonitorControl

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display. Use Apple Keyboard keys or custom shortcuts. Shows the native macOS OSDs.

SwiftMIT Licensemacoskeyboard
monitorcontrol.app
33.8k983
shadowsocks/ShadowsocksX-NG

Next Generation of ShadowsocksX

SwiftGNU General Public License v3.0shadowsocksswift
32.9k7.8k
kodecocodes/swift-algorithm-club

Algorithms and data structures in Swift, with explanations!

SwiftMIT Licenseswiftdata-structures
29.1k5k
jordanbaird/Ice

Powerful menu bar manager for macOS

SwiftGNU General Public License v3.0macosmenubar
icemenubar.app
29k824
airbnb/lottie-ios

An iOS library to natively render After Effects vector animations

SwiftApache License 2.0animationbodymovin
lottie.airbnb.tech
26.8k3.8k