File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ Simply add the following lines to your `Podfile`:
5151# required by Cocoapods 0.36.0.rc.1 for Swift Pods
5252use_frameworks!
5353
54- pod ' RSBarcodes_Swift' , ' ~> 5.1.0 '
54+ pod ' RSBarcodes_Swift' , ' ~> 5.1.1 '
5555```
5656
5757You will need to import RSBarcodes_Swift manually in the ViewController file after creating the file using wizard.
@@ -63,7 +63,7 @@ You will need to import RSBarcodes_Swift manually in the ViewController file aft
6363Simply add the following line to your ` Cartfile ` :
6464
6565``` ruby
66- github " yeahdongcn/RSBarcodes_Swift" >= 5.1 .0
66+ github " yeahdongcn/RSBarcodes_Swift" >= 5.1 .1
6767```
6868
6969You will need to import RSBarcodes_Swift manually in the ViewController file after creating the file using wizard.
Original file line number Diff line number Diff line change 11Pod ::Spec . new do |s |
22 s . name = "RSBarcodes_Swift"
3- s . version = "5.1.0 "
3+ s . version = "5.1.1 "
44 s . summary = "1D and 2D barcodes reader and generators for iOS 9 with delightful controls. Now Swift. "
55 s . homepage = "https://github.com/yeahdongcn/RSBarcodes_Swift"
66 s . license = { :type => 'MIT' , :file => 'LICENSE.md' }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import AVFoundation
1212import CoreImage
1313
1414let DIGITS_STRING = " 0123456789 "
15+ let BARCODE_DEFAULT_HEIGHT = 28
1516
1617// Controls the amount of additional data encoded in the output image to provide error correction.
1718// Higher levels of error correction result in larger output images but allow larger areas of the code to be damaged or obscured without.
@@ -106,9 +107,13 @@ open class RSAbstractCodeGenerator : RSCodeGenerator {
106107 // Top spacing = 1.5
107108 // Bottom spacing = 2
108109 // Left & right spacing = 2
109- // Height = 28
110110 let width = length + 4
111- let size = CGSize ( width: CGFloat ( width) , height: 28 )
111+ // Calculate the correct aspect ratio, so that the resulting image can be resized to the target size
112+ var height = BARCODE_DEFAULT_HEIGHT
113+ if let targetSize = targetSize {
114+ height = Int ( targetSize. height / targetSize. width * CGFloat( width) )
115+ }
116+ let size = CGSize ( width: CGFloat ( width) , height: CGFloat ( height) )
112117 UIGraphicsBeginImageContextWithOptions ( size, false , 1 )
113118 if let context = UIGraphicsGetCurrentContext ( ) {
114119 context. setShouldAntialias ( false )
You can’t perform that action at this time.
0 commit comments