Fixing example project

This commit is contained in:
Yannick Loriot 2018-12-28 15:31:01 +01:00
parent a8b4576243
commit 20cb403460
6 changed files with 17 additions and 13 deletions

View File

@ -3,6 +3,7 @@
## Version 10.0.0 ## Version 10.0.0
- [ADD] Allowing the scan area configuration (#157 #106) - [ADD] Allowing the scan area configuration (#157 #106)
- [UPDATE] The `showOverlayView` builder property is now `false` by default
## [Version 9.0.0](https://github.com/yannickl/QRCodeReader.swift/releases/tag/9.0.0) ## [Version 9.0.0](https://github.com/yannickl/QRCodeReader.swift/releases/tag/9.0.0)
Release on 2018-09-19 Release on 2018-09-19

View File

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<scenes> <scenes>
@ -23,7 +22,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MLx-jM-72O"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MLx-jM-72O">
<rect key="frame" x="27.5" y="258" width="320" height="150"/> <rect key="frame" x="27.5" y="258.5" width="320" height="150"/>
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="P5n-CT-PTt"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="P5n-CT-PTt">
<rect key="frame" x="0.0" y="0.0" width="150" height="150"/> <rect key="frame" x="0.0" y="0.0" width="150" height="150"/>
@ -63,8 +62,8 @@
</constraints> </constraints>
</view> </view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ROG-L6-Gnz" customClass="QRCodeReaderView" customModule="QRCodeReader_swift" customModuleProvider="target"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ROG-L6-Gnz" customClass="QRCodeReaderView" customModule="QRCodeReader_swift" customModuleProvider="target">
<rect key="frame" x="87" y="42" width="200" height="200"/> <rect key="frame" x="87.5" y="42.5" width="200" height="200"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints> <constraints>
<constraint firstAttribute="width" secondItem="ROG-L6-Gnz" secondAttribute="height" multiplier="1:1" id="5Br-7H-vZp"/> <constraint firstAttribute="width" secondItem="ROG-L6-Gnz" secondAttribute="height" multiplier="1:1" id="5Br-7H-vZp"/>
<constraint firstAttribute="height" constant="200" id="m30-Dq-t2L"/> <constraint firstAttribute="height" constant="200" id="m30-Dq-t2L"/>

View File

@ -31,9 +31,12 @@ class ViewController: UIViewController, QRCodeReaderViewControllerDelegate {
@IBOutlet weak var previewView: QRCodeReaderView! { @IBOutlet weak var previewView: QRCodeReaderView! {
didSet { didSet {
previewView.setupComponents(with: QRCodeReaderViewControllerBuilder { previewView.setupComponents(with: QRCodeReaderViewControllerBuilder {
$0.reader = reader $0.reader = reader
$0.showTorchButton = false $0.showTorchButton = false
$0.showSwitchCameraButton = false $0.showSwitchCameraButton = false
$0.showCancelButton = false
$0.showOverlayView = true
$0.rectOfInterest = CGRect(x: 0.2, y: 0.2, width: 0.6, height: 0.6)
}) })
} }
} }
@ -43,7 +46,8 @@ class ViewController: UIViewController, QRCodeReaderViewControllerDelegate {
$0.reader = QRCodeReader(metadataObjectTypes: [.qr], captureDevicePosition: .back) $0.reader = QRCodeReader(metadataObjectTypes: [.qr], captureDevicePosition: .back)
$0.showTorchButton = true $0.showTorchButton = true
$0.preferredStatusBarStyle = .lightContent $0.preferredStatusBarStyle = .lightContent
$0.rectOfInterest = CGRect(x: 0.15, y: 0.15, width: 0.7, height: 0.7) $0.showOverlayView = true
$0.rectOfInterest = CGRect(x: 0.2, y: 0.2, width: 0.6, height: 0.6)
$0.reader.stopScanningWhenCodeIsFound = false $0.reader.stopScanningWhenCodeIsFound = false
} }
@ -126,7 +130,7 @@ class ViewController: UIViewController, QRCodeReaderViewControllerDelegate {
} }
func reader(_ reader: QRCodeReaderViewController, didSwitchCamera newCaptureDevice: AVCaptureDeviceInput) { func reader(_ reader: QRCodeReaderViewController, didSwitchCamera newCaptureDevice: AVCaptureDeviceInput) {
print("Switching capturing to: \(newCaptureDevice.device.localizedName)") print("Switching capture to: \(newCaptureDevice.device.localizedName)")
} }
func readerDidCancel(_ reader: QRCodeReaderViewController) { func readerDidCancel(_ reader: QRCodeReaderViewController) {

View File

@ -78,7 +78,7 @@ func reader(_ reader: QRCodeReaderViewController, didScanResult result: QRCodeRe
//By pressing on the switch camera button //By pressing on the switch camera button
func reader(_ reader: QRCodeReaderViewController, didSwitchCamera newCaptureDevice: AVCaptureDeviceInput) { func reader(_ reader: QRCodeReaderViewController, didSwitchCamera newCaptureDevice: AVCaptureDeviceInput) {
if let cameraName = newCaptureDevice.device.localizedName { if let cameraName = newCaptureDevice.device.localizedName {
print("Switching capturing to: \(cameraName)") print("Switching capture to: \(cameraName)")
} }
} }

View File

@ -126,7 +126,7 @@ final public class QRCodeReaderView: UIView, QRCodeReaderDisplayable {
// MARK: - Scan Result Indication // MARK: - Scan Result Indication
func startTimerForBorderReset() { func startTimerForBorderReset() {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(1)) { DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) {
if let ovl = self.overlayView as? ReaderOverlayView { if let ovl = self.overlayView as? ReaderOverlayView {
ovl.overlayColor = .white ovl.overlayColor = .white
} }

View File

@ -94,7 +94,7 @@ public final class QRCodeReaderViewControllerBuilder {
/** /**
Flag to display the guide view. Flag to display the guide view.
*/ */
public var showOverlayView = true public var showOverlayView = false
/** /**
Flag to display the guide view. Flag to display the guide view.