Commit before reworking

This commit is contained in:
Andrew Walz 2017-08-25 14:39:52 -06:00
parent e9ee6f0ebd
commit 4d98b5f3f7
2 changed files with 70 additions and 39 deletions

View file

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D17a" 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="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@ -19,11 +20,56 @@
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hke-fJ-4fX" customClass="SwiftyRecordButton" customModule="DemoSwiftyCam" customModuleProvider="target">
<rect key="frame" x="150" y="572" width="75" height="75"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="75" id="8Mb-dy-Ned"/>
<constraint firstAttribute="width" constant="75" id="YVv-UJ-n1R"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hS2-sy-kuv">
<rect key="frame" x="70" y="598" width="30" height="23"/>
<state key="normal" image="flipCamera"/>
<connections>
<action selector="cameraSwitchTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Du6-FK-hjA"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="stR-Rn-UdV">
<rect key="frame" x="275" y="594" width="18" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="8dD-oU-QV8"/>
<constraint firstAttribute="width" constant="18" id="rLN-FU-RYb"/>
</constraints>
<state key="normal" image="flashOutline"/>
<connections>
<action selector="toggleFlashTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="C5u-0g-Kim"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="hke-fJ-4fX" secondAttribute="bottom" constant="20" symbolic="YES" id="0OM-Pc-Ze1"/>
<constraint firstItem="hke-fJ-4fX" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="22M-gB-uKl"/>
<constraint firstItem="stR-Rn-UdV" firstAttribute="leading" secondItem="hke-fJ-4fX" secondAttribute="trailing" constant="50" id="4S2-fF-Ta9"/>
<constraint firstItem="hS2-sy-kuv" firstAttribute="centerY" secondItem="hke-fJ-4fX" secondAttribute="centerY" id="AuI-5x-aKM"/>
<constraint firstItem="hke-fJ-4fX" firstAttribute="leading" secondItem="hS2-sy-kuv" secondAttribute="trailing" constant="50" id="fY6-aF-vVL"/>
<constraint firstItem="stR-Rn-UdV" firstAttribute="centerY" secondItem="hke-fJ-4fX" secondAttribute="centerY" id="sJP-2Z-GAn"/>
</constraints>
</view>
<connections>
<outlet property="captureButton" destination="hke-fJ-4fX" id="nng-T2-6kL"/>
<outlet property="flashButton" destination="stR-Rn-UdV" id="WAJ-Ik-VF7"/>
<outlet property="flipCameraButton" destination="hS2-sy-kuv" id="lWF-Wl-Vg1"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
<resources>
<image name="flashOutline" width="18" height="30"/>
<image name="flipCamera" width="30" height="23"/>
</resources>
</document>

View file

@ -17,11 +17,12 @@ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
import UIKit
class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate {
var flipCameraButton: UIButton!
var flashButton: UIButton!
var captureButton: SwiftyRecordButton!
@IBOutlet weak var captureButton: SwiftyRecordButton!
@IBOutlet weak var flipCameraButton: UIButton!
@IBOutlet weak var flashButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
cameraDelegate = self
@ -29,7 +30,6 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate {
shouldUseDeviceOrientation = true
allowAutoRotate = true
audioEnabled = true
addButtons()
}
override var prefersStatusBarHidden: Bool {
@ -38,6 +38,9 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// view.bringSubview(toFront: captureButton)
view.bringSubview(toFront: flipCameraButton)
view.bringSubview(toFront: flashButton)
}
func swiftyCam(_ swiftyCam: SwiftyCamViewController, didTake photo: UIImage) {
@ -95,36 +98,18 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate {
print(camera)
}
@objc private func cameraSwitchAction(_ sender: Any) {
switchCamera()
}
@objc private func toggleFlashAction(_ sender: Any) {
flashEnabled = !flashEnabled
if flashEnabled == true {
flashButton.setImage(#imageLiteral(resourceName: "flash"), for: UIControlState())
} else {
flashButton.setImage(#imageLiteral(resourceName: "flashOutline"), for: UIControlState())
}
}
private func addButtons() {
captureButton = SwiftyRecordButton(frame: CGRect(x: view.frame.midX - 37.5, y: view.frame.height - 100.0, width: 75.0, height: 75.0))
self.view.addSubview(captureButton)
captureButton.delegate = self
flipCameraButton = UIButton(frame: CGRect(x: (((view.frame.width / 2 - 37.5) / 2) - 15.0), y: view.frame.height - 74.0, width: 30.0, height: 23.0))
flipCameraButton.setImage(#imageLiteral(resourceName: "flipCamera"), for: UIControlState())
flipCameraButton.addTarget(self, action: #selector(cameraSwitchAction(_:)), for: .touchUpInside)
self.view.addSubview(flipCameraButton)
let test = CGFloat((view.frame.width - (view.frame.width / 2 + 37.5)) + ((view.frame.width / 2) - 37.5) - 9.0)
flashButton = UIButton(frame: CGRect(x: test, y: view.frame.height - 77.5, width: 18.0, height: 30.0))
flashButton.setImage(#imageLiteral(resourceName: "flashOutline"), for: UIControlState())
flashButton.addTarget(self, action: #selector(toggleFlashAction(_:)), for: .touchUpInside)
self.view.addSubview(flashButton)
}
@IBAction func cameraSwitchTapped(_ sender: Any) {
switchCamera()
}
@IBAction func toggleFlashTapped(_ sender: Any) {
flashEnabled = !flashEnabled
if flashEnabled == true {
flashButton.setImage(#imageLiteral(resourceName: "flash"), for: UIControlState())
} else {
flashButton.setImage(#imageLiteral(resourceName: "flashOutline"), for: UIControlState())
}
}
}