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

Added ultra-wide camera feature and switching between the lenses (1x to 0.5x) #258

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CameraManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@
TargetAttributes = {
454C1F4019E82E2500C81915 = {
CreatedOnToolsVersion = 6.0.1;
DevelopmentTeam = QM7HJTY23M;
LastSwiftMigration = 1130;
ProvisioningStyle = Automatic;
};
Expand Down Expand Up @@ -412,7 +411,7 @@
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = QM7HJTY23M;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "Example App/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -433,7 +432,7 @@
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = QM7HJTY23M;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = camera/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
56 changes: 33 additions & 23 deletions Example App/Base.lproj/Main.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="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="bhK-VL-qY4">
<device id="retina4_0" orientation="portrait" appearance="light"/>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="bhK-VL-qY4">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -16,32 +16,32 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleAspectFit" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jaF-q9-Eli" userLabel="Header">
<rect key="frame" x="0.0" y="0.0" width="320" height="60"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="104"/>
<subviews>
<imageView contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Dl4-Bd-nCD" userLabel="Flash">
<rect key="frame" x="0.0" y="0.0" width="80" height="60"/>
<rect key="frame" x="0.0" y="44" width="103.5" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="G26-xV-Daw"/>
</constraints>
</imageView>
<imageView contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Nwk-zu-ilR" userLabel="Output">
<rect key="frame" x="80" y="0.0" width="80" height="60"/>
<rect key="frame" x="103.5" y="44" width="103.5" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="Tbv-ym-RE2"/>
</constraints>
</imageView>
<imageView contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Ver-vU-Fv7" userLabel="Camera">
<rect key="frame" x="160" y="0.0" width="80" height="60"/>
<rect key="frame" x="207" y="44" width="103.5" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="gpP-Pw-2aI"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="High" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yae-yJ-Gt7" userLabel="Quality">
<rect key="frame" x="240" y="0.0" width="80" height="60"/>
<rect key="frame" x="310.5" y="44" width="103.5" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="2Da-tr-Vk4"/>
</constraints>
Expand All @@ -67,22 +67,22 @@
</constraints>
</view>
<view clipsSubviews="YES" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="EI2-CK-oqA" userLabel="cameraView">
<rect key="frame" x="0.0" y="60" width="320" height="432"/>
<rect key="frame" x="0.0" y="104" width="414" height="682"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="tintColor" red="0.48412352800369263" green="0.74477618932723999" blue="0.19113841652870178" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Tap here to enable camera access and take great pictures" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2bK-wq-6Rf">
<rect key="frame" x="0.0" y="60" width="320" height="432"/>
<rect key="frame" x="0.0" y="104" width="414" height="682"/>
<color key="backgroundColor" red="0.094117647058823528" green="0.49019607843137253" blue="0.98431372549019602" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" weight="thin" pointSize="25"/>
<color key="textColor" red="0.98039215690000003" green="0.98039215690000003" blue="0.97254901959999995" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1mh-eT-4mm" userLabel="Footer">
<rect key="frame" x="0.0" y="492" width="320" height="76"/>
<rect key="frame" x="0.0" y="786" width="414" height="110"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2Cu-5B-8Wz">
<rect key="frame" x="135" y="13" width="50" height="50"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2Cu-5B-8Wz">
<rect key="frame" x="182" y="13" width="50" height="50"/>
<color key="backgroundColor" red="0.094117647058823528" green="0.49019607843137253" blue="0.98431372549019602" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="oe2-j1-8SK"/>
Expand All @@ -102,8 +102,8 @@
<action selector="recordButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="cfr-ZF-Fpz"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3uo-sy-vdf">
<rect key="frame" x="220" y="23" width="70" height="30"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3uo-sy-vdf">
<rect key="frame" x="314" y="23" width="70" height="30"/>
<fontDescription key="fontDescription" type="system" weight="thin" pointSize="15"/>
<state key="normal" title="Locate Me">
<color key="titleColor" red="0.094117647058823528" green="0.49019607843137253" blue="0.98431372549019602" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand All @@ -112,12 +112,21 @@
<action selector="locateMeButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="huy-LH-yAF"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1x" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f7s-D3-6ba" userLabel="Lens Label">
<rect key="frame" x="30" y="27.5" width="144" height="21"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.015686274509803921" green="0.054901960784313725" blue="0.10196078431372549" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="2Cu-5B-8Wz" firstAttribute="top" secondItem="1mh-eT-4mm" secondAttribute="top" constant="13" id="BgG-Xj-ZmZ"/>
<constraint firstItem="3uo-sy-vdf" firstAttribute="centerY" secondItem="2Cu-5B-8Wz" secondAttribute="centerY" id="CRd-1J-g7P"/>
<constraint firstAttribute="trailing" secondItem="f7s-D3-6ba" secondAttribute="trailing" constant="240" id="EcU-LJ-cdp"/>
<constraint firstItem="2Cu-5B-8Wz" firstAttribute="centerX" secondItem="1mh-eT-4mm" secondAttribute="centerX" id="JN1-xZ-LeR"/>
<constraint firstItem="f7s-D3-6ba" firstAttribute="centerY" secondItem="2Cu-5B-8Wz" secondAttribute="centerY" id="X0S-Xw-s1d"/>
<constraint firstItem="f7s-D3-6ba" firstAttribute="leading" secondItem="1mh-eT-4mm" secondAttribute="leading" constant="30" id="cY8-ZN-ahP"/>
<constraint firstAttribute="trailing" secondItem="3uo-sy-vdf" secondAttribute="trailing" constant="30" id="cih-vq-fzc"/>
<constraint firstItem="3uo-sy-vdf" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="1mh-eT-4mm" secondAttribute="leading" constant="20" symbolic="YES" id="vWR-TH-d5A"/>
</constraints>
Expand Down Expand Up @@ -160,14 +169,15 @@
<outlet property="flashModeImageView" destination="Dl4-Bd-nCD" id="cAO-8p-HTZ"/>
<outlet property="footerView" destination="1mh-eT-4mm" id="5aT-gQ-xSA"/>
<outlet property="headerView" destination="jaF-q9-Eli" id="ws8-fM-eLu"/>
<outlet property="lensLabel" destination="f7s-D3-6ba" id="g7i-7V-uRg"/>
<outlet property="locationButton" destination="3uo-sy-vdf" id="BPV-S4-Zbo"/>
<outlet property="outputImageView" destination="Nwk-zu-ilR" id="dol-Lo-s9p"/>
<outlet property="qualityLabel" destination="yae-yJ-Gt7" id="ov3-8B-KCh"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="714" y="96"/>
<point key="canvasLocation" x="712.5" y="95.070422535211264"/>
</scene>
<!--Image-->
<scene sceneID="EDW-uZ-RNP">
Expand All @@ -178,13 +188,13 @@
<viewControllerLayoutGuide type="bottom" id="qVT-yr-0bo"/>
</layoutGuides>
<view key="view" contentMode="scaleAspectFill" id="Qhk-xW-6b1">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="427-Be-jHr" userLabel="Header">
<rect key="frame" x="0.0" y="0.0" width="320" height="60"/>
<rect key="frame" x="0.0" y="44" width="414" height="60"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hZh-Id-5lE">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hZh-Id-5lE">
<rect key="frame" x="15" y="15" width="60" height="32"/>
<color key="backgroundColor" red="0.094117647058823528" green="0.49019607843137253" blue="0.98431372549019602" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
Expand All @@ -208,11 +218,11 @@
</constraints>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" adjustsImageSizeForAccessibilityContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="v1g-94-paQ">
<rect key="frame" x="0.0" y="60" width="320" height="432"/>
<rect key="frame" x="0.0" y="104" width="414" height="682"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cc6-X6-k9M" userLabel="Footer">
<rect key="frame" x="0.0" y="492" width="320" height="76"/>
<rect key="frame" x="0.0" y="786" width="414" height="76"/>
<color key="backgroundColor" red="0.015686274510000001" green="0.054901960780000002" blue="0.1019607843" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="76" id="WF8-cT-Bp1"/>
Expand Down Expand Up @@ -254,7 +264,7 @@
<toolbarItems/>
<nil key="simulatedStatusBarMetrics"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="Gas-AK-MC9">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand Down
17 changes: 9 additions & 8 deletions Example App/ImageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@
import CameraManager
import UIKit

@available(iOS 13.0, *)
class ImageViewController: UIViewController {
var image: UIImage?
var cameraManager: CameraManager?
@IBOutlet var imageView: UIImageView!

override func viewDidLoad() {
super.viewDidLoad()
navigationController?.navigationBar.isHidden = true

guard let validImage = image else {
return
}

imageView.image = validImage

if cameraManager?.cameraDevice == .front {
switch validImage.imageOrientation {
case .up, .down:
Expand All @@ -33,20 +34,20 @@ class ImageViewController: UIViewController {
}
}
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

@IBAction func closeButtonTapped(_: Any) {
navigationController?.popViewController(animated: true)
}

override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return .portrait
}

override var shouldAutorotate: Bool {
return false
}
Expand Down
Loading