diff --git a/EFQRCode.podspec b/EFQRCode.podspec
index 6c5403a7..95e19070 100644
--- a/EFQRCode.podspec
+++ b/EFQRCode.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'EFQRCode'
-s.version = '4.0.0'
+s.version = '4.1.0'
s.summary = 'A better way to operate quick response code in Swift.'
s.description = <<-DESC
@@ -22,5 +22,6 @@ s.tvos.deployment_target = '9.0'
s.requires_arc = true
s.source_files = 'Source/**/*.{h,swift}'
+
s.frameworks = 'ImageIO'
end
diff --git a/Examples/iOS/Resources/Info.plist b/Examples/iOS/Resources/Info.plist
index 283c12d7..59c94d7d 100755
--- a/Examples/iOS/Resources/Info.plist
+++ b/Examples/iOS/Resources/Info.plist
@@ -15,11 +15,11 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 4.0.0
+ 4.1.0
CFBundleSignature
????
CFBundleVersion
- 4.0.0.0
+ 4.1.0.0
LSRequiresIPhoneOS
NSAppleMusicUsageDescription
diff --git a/Examples/macOS/macOS Example/Info.plist b/Examples/macOS/macOS Example/Info.plist
index 8cc634ed..9c73a25d 100644
--- a/Examples/macOS/macOS Example/Info.plist
+++ b/Examples/macOS/macOS Example/Info.plist
@@ -17,9 +17,9 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 4.0.0
+ 4.1.0
CFBundleVersion
- 4.0.0.0
+ 4.1.0.0
LSApplicationCategoryType
public.app-category.developer-tools
LSMinimumSystemVersion
diff --git a/Examples/tvOS/tvOS Example/Info.plist b/Examples/tvOS/tvOS Example/Info.plist
index da38a2d4..f500fec0 100644
--- a/Examples/tvOS/tvOS Example/Info.plist
+++ b/Examples/tvOS/tvOS Example/Info.plist
@@ -15,9 +15,9 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 4.0.0
+ 4.1.0
CFBundleVersion
- 4.0.0.0
+ 4.1.0.0
LSRequiresIPhoneOS
UIMainStoryboardFile
diff --git a/README.md b/README.md
index bfeeadb1..83a4621f 100644
--- a/README.md
+++ b/README.md
@@ -24,9 +24,9 @@ EFQRCode is a lightweight, pure-Swift library for generating pretty QRCode image
## Overview
-![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode1.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode2.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode3.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode4.jpg)
-:---------------------:|:---------------------:|:---------------------:|:---------------------:
![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode5.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode6.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode7.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode8.jpg)
+:---------------------:|:---------------------:|:---------------------:|:---------------------:
+![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF1.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF2.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF7.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF8.gif)
## Demo
@@ -161,7 +161,31 @@ Result:
-#### 4. Next
+#### 4. Generation from GIF
+
+You can create GIF QRCode with function `generateWithGIF` of class `EFQRCode`, for example:
+
+```swift
+// data: Data of input GIF
+// generator: An object of EFQRCodeGenerator, use for setting
+// pathToSave (Optional): Path to save the output GIF, default is temp path
+// delay (Optional): Output QRCode GIF delay, default is same as input GIF
+// loopCount (Optional): Output QRCode GIF loopCount, default is same as input GIF
+```
+
+```swift
+if let qrcodeData = EFQRCode.generateWithGIF(data: data, generator: generator) {
+ print("Create QRCode image success.")
+} else {
+ print("Create QRCode image failed!")
+}
+```
+
+You can get more information from the demo, result will like this:
+
+
+
+#### 5. Next
Learn more from [User Guide](https://github.com/EyreFree/EFQRCode/blob/master/USERGUIDE.md).
diff --git a/README_CN.md b/README_CN.md
index eed9eb62..737c09b2 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -24,9 +24,9 @@ EFQRCode 是一个轻量级的、用来生成和识别二维码的纯 Swift 库
## 概述
-![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode1.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode2.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode3.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode4.jpg)
-:---------------------:|:---------------------:|:---------------------:|:---------------------:
![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode5.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode6.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode7.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCode8.jpg)
+:---------------------:|:---------------------:|:---------------------:|:---------------------:
+![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF1.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF2.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF7.gif)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/QRCodeGIF8.gif)
## 示例
@@ -139,11 +139,11 @@ if let testImage = UIImage(named: "test.png")?.toCGImage() {
根据所输入参数创建各种艺术二维码图片,快速使用方式如下:
```swift
-// content: Content of QR Code
-// size (Optional): Width and height of image
-// backgroundColor (Optional): Background color of QRCode
-// foregroundColor (Optional): Foreground color of QRCode
-// watermark (Optional): Background image of QRCode
+// content: 二维码内容
+// size (Optional): 二维码宽高
+// backgroundColor (Optional): 二维码背景色
+// foregroundColor (Optional): 二维码前景色
+// watermark (Optional): 水印图
```
```swift
@@ -161,7 +161,31 @@ if let tryImage = EFQRCode.generate(
-#### 4. 接下来
+#### 4. 动态二维码
+
+可通过 EFQRCode 的类方法 generateWithGIF 来创建 GIF 二维码,使用方式如下:
+
+```swift
+// data: 输入的 GIF 图片的数据
+// generator: 一个用来获取设置的 EFQRCodeGenerator 对象
+// pathToSave (Optional): 用来存储 GIF 的路径,默认不填的话会存储在临时路径
+// delay (Optional): 输出的动态 QRCode 的帧间延时,默认不填的话从输入的 GIF 图片获取
+// loopCount (Optional): 输出的动态 QRCode 的循环次数,默认不填的话从输入的 GIF 图片获取
+```
+
+```swift
+if let qrcodeData = EFQRCode.generateWithGIF(data: data, generator: generator) {
+ print("Create QRCode image success.")
+} else {
+ print("Create QRCode image failed!")
+}
+```
+
+你可以通过查看 Demo 代码的方式来获取更多信息,结果预览:
+
+
+
+#### 5. 接下来
查看 [用户手册](https://github.com/EyreFree/EFQRCode/blob/master/USERGUIDE_CN.md) 了解更多细节。
diff --git a/Source/EFQRCode+GIF.swift b/Source/EFQRCode+GIF.swift
index 6bc7fcda..9fa95345 100644
--- a/Source/EFQRCode+GIF.swift
+++ b/Source/EFQRCode+GIF.swift
@@ -38,7 +38,7 @@ public extension EFQRCode {
public static var tempResultPath: URL?
- public static func generateWithGIF(data: Data, generator: EFQRCodeGenerator, delay: Double? = nil, loopCount: Int? = nil) -> Data? {
+ public static func generateWithGIF(data: Data, generator: EFQRCodeGenerator, pathToSave: URL? = nil, delay: Double? = nil, loopCount: Int? = nil) -> Data? {
if let source = CGImageSourceCreateWithData(data as CFData, nil) {
var frames = source.toCGImages()
@@ -85,7 +85,7 @@ public extension EFQRCode {
}
if let fileProperties = fileProperties, framePropertiesArray.count == frames.count {
- if let url = frames.saveToGIFFile(framePropertiesArray: framePropertiesArray, fileProperties: fileProperties) {
+ if let url = frames.saveToGIFFile(framePropertiesArray: framePropertiesArray, fileProperties: fileProperties, url: pathToSave) {
return try? Data(contentsOf: url)
}
}
diff --git a/USERGUIDE.md b/USERGUIDE.md
index 560961a7..142c0054 100644
--- a/USERGUIDE.md
+++ b/USERGUIDE.md
@@ -256,3 +256,33 @@ Threshold for binarization (Only for mode binarization).
Origin | 0.3 | 0.5 | 0.8
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold0.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold1.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold2.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold3.jpg)
+
+### 3. Generation from GIF
+
+1. First you should get the complete data of a GIF file, type is `Data`, can not get from `UIImage` or you will only get the first frame;
+2. Then you can create GIF QRCode with function `generateWithGIF` of class `EFQRCode`, for example:
+
+```swift
+// data: Data of input GIF
+// generator: An object of EFQRCodeGenerator, use for setting
+// pathToSave (Optional): Path to save the output GIF, default is temp path
+// delay (Optional): Output QRCode GIF delay, default is same as input GIF
+// loopCount (Optional): Output QRCode GIF loopCount, default is same as input GIF
+```
+
+The `generator` here is an object of class `EFQRCodeGenerator`, to process each frame in GIF, you can find the use of it above.
+
+```swift
+if let qrcodeData = EFQRCode.generateWithGIF(data: data, generator: generator) {
+ print("Create QRCode image success.")
+} else {
+ print("Create QRCode image failed!")
+}
+```
+
+You can get more information from the demo, result will like this:
+
+
+
+3. Now you can get the complete data of output QRCode GIF, next we can save it to local path / system photo library / upload to server or some other things you want to do;
+4. Emmmmmm, note that the `tempResultPath` of `EFQRcode` is the path of data of GIF of last generation.
diff --git a/USERGUIDE_CN.md b/USERGUIDE_CN.md
index c801991d..ccb002d2 100644
--- a/USERGUIDE_CN.md
+++ b/USERGUIDE_CN.md
@@ -256,3 +256,33 @@ square | circle
Origin | 0.3 | 0.5 | 0.8
:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:
![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold0.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold1.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold2.jpg)|![](https://raw.githubusercontent.com/EyreFree/EFQRCode/assets/binarizationThreshold3.jpg)
+
+### 3. 动态二维码
+
+1. 首先需要从网络/本地/相册等来源获取输入的 GIF 文件的完整数据,要 Data 类型,不能通过 UIImage 来获取,不然的话只能取到 GIF 的第一帧;
+2. 然后可以通过 EFQRCode 的类方法 generateWithGIF 来创建 GIF 二维码,使用方式如下:
+
+```swift
+// data: 输入的 GIF 图片的数据
+// generator: 一个用来获取设置的 EFQRCodeGenerator 对象
+// pathToSave (Optional): 用来存储 GIF 的路径,默认不填的话会存储在临时路径
+// delay (Optional): 输出的动态 QRCode 的帧间延时,默认不填的话从输入的 GIF 图片获取
+// loopCount (Optional): 输出的动态 QRCode 的循环次数,默认不填的话从输入的 GIF 图片获取
+```
+
+这里的 generator 是一个 EFQRCodeGenerator 类型的对象,用来对 GIF 中的每一帧进行处理,详细用法参考上文。
+
+```swift
+if let qrcodeData = EFQRCode.generateWithGIF(data: data, generator: generator) {
+ print("Create QRCode image success.")
+} else {
+ print("Create QRCode image failed!")
+}
+```
+
+你可以通过查看 Demo 代码的方式来获取更多信息,结果预览:
+
+
+
+3. 到这里我们已经获取了生成的 GIF 文件的完整数据,接下来可以进行将返回的 Data 类型的数据直接保存到本地/系统相册/上传到服务器等你想做的操作;
+4. 唔,这里有一个隐藏设定,最近一次生成的 GIF 二维码是保存在 EFQRcode 类的 tempResultPath 所在的位置的。