Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Torch Button custom sizing #113

Merged
merged 11 commits into from
Jan 23, 2020
7 changes: 4 additions & 3 deletions CardScan/Assets/CardScan.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -100,7 +100,6 @@
<constraint firstItem="X5c-eH-4ZR" firstAttribute="top" secondItem="hHp-1y-YRu" secondAttribute="top" id="Icy-Hp-kZm"/>
<constraint firstItem="GI2-Cu-50E" firstAttribute="centerX" secondItem="hHp-1y-YRu" secondAttribute="centerX" id="Oti-bY-2qM"/>
<constraint firstItem="GI2-Cu-50E" firstAttribute="centerY" secondItem="hHp-1y-YRu" secondAttribute="centerY" id="ShD-kV-AJC"/>
<constraint firstItem="GI2-Cu-50E" firstAttribute="centerX" secondItem="hHp-1y-YRu" secondAttribute="centerX" id="dUY-ZN-jJY"/>
</constraints>
</view>
</subviews>
Expand Down Expand Up @@ -222,6 +221,8 @@
<outlet property="scanCardLabel" destination="vfu-3N-l48" id="2kI-61-Gm4"/>
<outlet property="skipButton" destination="X5c-eH-4ZR" id="4S7-9x-HVa"/>
<outlet property="torchButton" destination="GI2-Cu-50E" id="F1H-K0-X4c"/>
<outlet property="torchButtonHeightConstraint" destination="FGW-3T-gOM" id="0Ot-fv-8f4"/>
<outlet property="torchButtonWidthConstraint" destination="sCb-37-0DF" id="U6d-Lu-0UR"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="LMM-sw-EX2" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
7 changes: 7 additions & 0 deletions CardScan/Classes/ScanViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ import UIKit
@IBOutlet weak var regionOfInterestAspectConstraint: NSLayoutConstraint!

@IBOutlet weak var torchButton: UIButton!
@IBOutlet weak var torchButtonWidthConstraint: NSLayoutConstraint!
@IBOutlet weak var torchButtonHeightConstraint: NSLayoutConstraint!
public var torchButtonSize: CGSize?
@IBOutlet weak var cornerView: CornerView!
var cornerBorderColor = UIColor.green.cgColor
var denyPermissionTitle = "Need camera access"
Expand Down Expand Up @@ -233,6 +236,10 @@ import UIKit
if let color = self.cornerColor {
self.cornerBorderColor = color.cgColor
}
if let size = self.torchButtonSize {
self.torchButtonWidthConstraint.constant = size.width
self.torchButtonHeightConstraint.constant = size.height
}
}

func showDenyAlert() {
Expand Down
2 changes: 2 additions & 0 deletions Example/CardScan/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class ViewController: UIViewController, ScanEvents, ScanDelegate, FullScanString

vc.cornerColor = UIColor.blue
vc.torchButtonImage = ScanViewController.cameraImage()

vc.torchButtonSize = CGSize(width: 44, height: 44)

self.present(vc, animated: true)
}
Expand Down
1 change: 1 addition & 0 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.