EFQRCode
public class EFQRCode
EFQRCode - A lightweight QR code generator and recognizer for iOS, macOS, tvOS and watchOS.
EFQRCode is a powerful and flexible QR code library that supports:
- QR code generation with various styles and customizations
- QR code recognition from images
- Multiple output formats (PNG, JPEG, GIF, APNG, PDF, SVG, Video)
- Animated QR codes
- Custom styling with icons and watermarks
- Error correction levels
- Cross-platform support (iOS, macOS, tvOS, watchOS, visionOS)
## Basic Usage
// Generate a basic QR code
let generator = try EFQRCode.Generator("Hello World")
let image = try generator.toImage(width: 200)
## Features
- Multiple Styles: Basic, Bubble, 2.5D, Image, Line, Random Rectangle, and more
- Custom Icons: Add custom icons to QR codes
- Watermarks: Overlay watermarks on QR codes
- Animated QR Codes: Create animated QR codes with GIF and APNG support
- Video Export: Export QR codes as video files (MOV, M4V, MP4)
- High Performance: Optimized for performance with caching and efficient algorithms
- Cross Platform: Works on iOS, macOS, tvOS, and watchOS
## Requirements
- iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ / visionOS 1.0+
- Swift 5.0+
- Xcode 13.0+
-
A QR code generator that creates QR codes with various styles and output formats.
The
Generator
class is the main entry point for creating QR codes in EFQRCode. It supports multiple initialization methods, various output formats, and custom styling.## Basic Usage
// Create a generator with text let generator = try EFQRCode.Generator("Hello World") // Generate an image let image = try generator.toImage(width: 200) // Generate PNG data let pngData = try generator.toPNGData(width: 200)
## Initialization
You can initialize a generator with:
- String content with encoding
- Data content
- Existing QRCode object
## Output Formats
The generator supports multiple output formats:
- Images: PNG, JPEG, SVG
- Animated: GIF, APNG
- Video: MOV, M4V, MP4
- Document: PDF
## Styling
QR codes can be styled with various styles including:
- Basic styles
- Bubble styles
- 2.5D styles
- Image-based styles
- Custom icons and watermarks
## Error Handling
The generator throws
EFQRCodeError
for various error conditions:- Invalid text encoding
- Data too large for QR code capacity
- Invalid style configurations
- Output format errors
Declaration
Swift
class Generator
-
A QR code recognizer that extracts QR code content from images.
The
Recognizer
class provides functionality to detect and decode QR codes from images. It uses Core Image’s QR code detection capabilities with high accuracy settings and fallback to low accuracy if needed.## Basic Usage
// Create a recognizer with an image let recognizer = EFQRCode.Recognizer(image: qrCodeImage) // Recognize QR code content let contents = recognizer.recognize() // Check if any QR codes were found if !contents.isEmpty { print("Found QR code: \(contents[0])") }
## Features
- High Accuracy: Uses high accuracy detection by default
- Fallback Detection: Automatically falls back to low accuracy if no QR codes are found
- Multiple QR Codes: Can detect multiple QR codes in a single image
- Caching: Results are cached for performance
- Image Updates: Automatically clears cache when image is updated
## Requirements
- Core Image framework must be available
- Image must contain recognizable QR code content
Declaration
Swift
class Recognizer