@@ -48,7 +48,7 @@ controller.codeDelegate = self
4848controller.errorDelegate = self
4949controller.dismissalDelegate = self
5050
51- presentViewController (controller, animated : true , completion : nil )
51+ present (controller, animated : true , completion : nil )
5252```
5353
5454<div align =" center " >
@@ -73,7 +73,7 @@ Use `BarcodeScannerCodeDelegate` when you want to get the captured code back.
7373``` swift
7474extension ViewController : BarcodeScannerCodeDelegate {
7575
76- func barcodeScanner (controller : BarcodeScannerController, didCapturedCode code : String , type : String ) {
76+ func barcodeScanner (_ controller : BarcodeScannerController, didCaptureCode code : String , type : String ) {
7777 print (code)
7878 controller.reset ()
7979 }
@@ -86,7 +86,7 @@ Use `BarcodeScannerErrorDelegate` when you want to handle session errors.
8686``` swift
8787extension ViewController : BarcodeScannerErrorDelegate {
8888
89- func barcodeScanner (controller : BarcodeScannerController, didReceiveError error : ErrorType ) {
89+ func barcodeScanner (_ controller : BarcodeScannerController, didReceiveError error : Error ) {
9090 print (error)
9191 }
9292}
@@ -101,8 +101,8 @@ presented initially.
101101``` swift
102102extension ViewController : BarcodeScannerDismissalDelegate {
103103
104- func barcodeScannerDidDismiss (controller : BarcodeScannerController) {
105- controller.dismissViewControllerAnimated ( true , completion : nil )
104+ func barcodeScannerDidDismiss (_ controller : BarcodeScannerController) {
105+ controller.dismiss ( animated : true , completion : nil )
106106 }
107107}
108108```
@@ -123,9 +123,9 @@ on the code. When the task is done you have 3 options to proceed:
1231231 . Dismiss ` BarcodeScannerController ` and show your results.
124124
125125 ``` swift
126- func barcodeScanner (controller : BarcodeScannerController, didCapturedCode code : String ) {
126+ func barcodeScanner (_ controller : BarcodeScannerController, didCaptureCode code : String , type : String ) {
127127 // Code processing
128- controller.dismissViewControllerAnimated ( true , completion : nil )
128+ controller.dismiss ( animated : true , completion : nil )
129129 }
130130 ```
1311312 . Show an error message and switch back to the scanning mode (for example,
@@ -136,25 +136,24 @@ when there is no product found with a given barcode in your database):
136136 </div ><br />
137137
138138 ``` swift
139- func barcodeScanner (controller : BarcodeScannerController, didCapturedCode code : String ) {
139+ func barcodeScanner (_ controller : BarcodeScannerController, didCaptureCode code : String , type : String ) {
140140 // Code processing
141- controller.resetWithError (" Error message" )
141+ controller.resetWithError (message : " Error message" )
142142 // If message is not provided the default message from the config will be used instead.
143143 }
144144 ```
1451453 . Reset the controller to the scanning mode (with or without animation):
146146
147147 ``` swift
148- func barcodeScanner (controller : BarcodeScannerController, didCapturedCode code : String ) {
148+ func barcodeScanner (_ controller : BarcodeScannerController, didCaptureCode code : String , type : String ) {
149149 // Code processing
150150 controller.reset (animated : true )
151151 }
152152 ```
153153
154- If you want to do continuous barcode scanning just set the ` oneTimeSearch `
154+ If you want to do continuous barcode scanning just set the ` isOneTimeSearch `
155155property on your ` BarcodeScannerController ` instance to ` false ` .
156156
157-
158157### Customization
159158
160159We styled ** BarcodeScanner** to make it look nice, but feel free to customize
@@ -173,20 +172,20 @@ BarcodeScanner.Info.settingsText = NSLocalizedString(
173172 " In order to scan barcodes you have to allow camera under your settings." , comment : " " )
174173
175174// Fonts
176- BarcodeScanner.Title .font = UIFont.boldSystemFontOfSize ( 17 )
177- BarcodeScanner.CloseButton .font = UIFont.boldSystemFontOfSize ( 17 )
178- BarcodeScanner.SettingsButton .font = UIFont.boldSystemFontOfSize ( 17 )
179- BarcodeScanner.Info .font = UIFont.boldSystemFontOfSize ( 14 )
180- BarcodeScanner.Info .loadingFont = UIFont.boldSystemFontOfSize ( 16 )
175+ BarcodeScanner.Title .font = UIFont.boldSystemFont ( ofSize : 17 )
176+ BarcodeScanner.CloseButton .font = UIFont.boldSystemFont ( ofSize : 17 )
177+ BarcodeScanner.SettingsButton .font = UIFont.boldSystemFont ( ofSize : 17 )
178+ BarcodeScanner.Info .font = UIFont.boldSystemFont ( ofSize : 14 )
179+ BarcodeScanner.Info .loadingFont = UIFont.boldSystemFont ( ofSize : 16 )
181180
182181// Colors
183- BarcodeScanner.Title .color = UIColor.blackColor ()
184- BarcodeScanner.CloseButton .color = UIColor.blackColor ()
185- BarcodeScanner.SettingsButton .color = UIColor.whiteColor ()
186- BarcodeScanner.Info .textColor = UIColor.blackColor ()
187- BarcodeScanner.Info .tint = UIColor.blackColor ()
188- BarcodeScanner.Info .loadingTint = UIColor.blackColor ()
189- BarcodeScanner.Info .notFoundTint = UIColor.redColor ()
182+ BarcodeScanner.Title .color = UIColor.black
183+ BarcodeScanner.CloseButton .color = UIColor.black
184+ BarcodeScanner.SettingsButton .color = UIColor.white
185+ BarcodeScanner.Info .textColor = UIColor.black
186+ BarcodeScanner.Info .tint = UIColor.black
187+ BarcodeScanner.Info .loadingTint = UIColor.black
188+ BarcodeScanner.Info .notFoundTint = UIColor.red
190189```
191190
192191## Installation
0 commit comments