Added ability to save photo and made an animation for it

This commit is contained in:
Alexander Munch-hansen 2017-08-01 13:38:18 +02:00
parent ae23766fe4
commit e4738a306e
7 changed files with 64 additions and 7 deletions

View File

@ -149,6 +149,7 @@
TargetAttributes = { TargetAttributes = {
ACAAF0011F2F93C600271C26 = { ACAAF0011F2F93C600271C26 = {
CreatedOnToolsVersion = 8.3.3; CreatedOnToolsVersion = 8.3.3;
DevelopmentTeam = HU6WPE737K;
ProvisioningStyle = Automatic; ProvisioningStyle = Automatic;
}; };
ACAAF0151F2F93C600271C26 = { ACAAF0151F2F93C600271C26 = {
@ -345,11 +346,14 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = HU6WPE737K;
INFOPLIST_FILE = "dcav-uploader/Info.plist"; INFOPLIST_FILE = "dcav-uploader/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.3; IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "space.guava.dcav-uploader"; PRODUCT_BUNDLE_IDENTIFIER = "space.guava-";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 3.0; SWIFT_VERSION = 3.0;
}; };
name = Debug; name = Debug;
@ -358,11 +362,14 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = HU6WPE737K;
INFOPLIST_FILE = "dcav-uploader/Info.plist"; INFOPLIST_FILE = "dcav-uploader/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.3; IPHONEOS_DEPLOYMENT_TARGET = 10.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "space.guava.dcav-uploader"; PRODUCT_BUNDLE_IDENTIFIER = "space.guava-";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 3.0; SWIFT_VERSION = 3.0;
}; };
name = Release; name = Release;

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "saved_image.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,5 +1,5 @@
<?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="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="8xC-Gn-SAo"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F2073" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="8xC-Gn-SAo">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
@ -76,6 +76,10 @@
<rect key="frame" x="16" y="383" width="343" height="2"/> <rect key="frame" x="16" y="383" width="343" height="2"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</progressView> </progressView>
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="savedImage" translatesAutoresizingMaskIntoConstraints="NO" id="ehT-4D-jVX">
<rect key="frame" x="105" y="177" width="167" height="135"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view> </view>
@ -88,6 +92,7 @@
<outlet property="dcavTextField" destination="9YY-rV-nVu" id="RPZ-ov-oMp"/> <outlet property="dcavTextField" destination="9YY-rV-nVu" id="RPZ-ov-oMp"/>
<outlet property="imageView" destination="3Cc-7Y-DVl" id="CcV-Us-W0x"/> <outlet property="imageView" destination="3Cc-7Y-DVl" id="CcV-Us-W0x"/>
<outlet property="labell" destination="Wr7-lK-wSY" id="u97-bt-PHA"/> <outlet property="labell" destination="Wr7-lK-wSY" id="u97-bt-PHA"/>
<outlet property="savedPhotoImageView" destination="ehT-4D-jVX" id="80l-aT-65F"/>
<outlet property="uploadProgressBar" destination="JEW-rQ-Kb1" id="zuQ-8e-GvG"/> <outlet property="uploadProgressBar" destination="JEW-rQ-Kb1" id="zuQ-8e-GvG"/>
</connections> </connections>
</viewController> </viewController>
@ -118,4 +123,7 @@
<point key="canvasLocation" x="-266" y="38"/> <point key="canvasLocation" x="-266" y="38"/>
</scene> </scene>
</scenes> </scenes>
<resources>
<image name="savedImage" width="320" height="240"/>
</resources>
</document> </document>

View File

@ -20,6 +20,10 @@
<string>1</string> <string>1</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSCameraUsageDescription</key>
<string>Need to access camera lol</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Plz give access</string>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>
@ -39,9 +43,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>NSPhotoLibraryUsageDescription</key>
<string>Plz give access</string>
<key>NSCameraUsageDescription</key>
<string>Need to access camera lol</string>
</dict> </dict>
</plist> </plist>

View File

@ -16,6 +16,7 @@ class ViewController: UIViewController, UINavigationControllerDelegate, UIImageP
@IBOutlet weak var dcavTextField: UITextField! @IBOutlet weak var dcavTextField: UITextField!
var responseString : String! var responseString : String!
@IBOutlet weak var uploadProgressBar: UIProgressView! @IBOutlet weak var uploadProgressBar: UIProgressView!
@IBOutlet weak var savedPhotoImageView: UIImageView!
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
@ -53,6 +54,20 @@ class ViewController: UIViewController, UINavigationControllerDelegate, UIImageP
} }
@IBAction func onSaveButton(_ sender: Any) { @IBAction func onSaveButton(_ sender: Any) {
UIImageWriteToSavedPhotosAlbum(imageView.image!, nil, nil, nil);
UIView.animate(withDuration: 0.5, delay:0.0, options:UIViewAnimationOptions.transitionFlipFromTop, animations: {
self.savedPhotoImageView.isHidden = false
self.savedPhotoImageView.alpha = 1
}, completion: { finished in
UIView.animate(withDuration: 0.5, delay:1, options:UIViewAnimationOptions.transitionCrossDissolve, animations: {
self.savedPhotoImageView.alpha = 0
}, completion: { finished in
self.savedPhotoImageView.isHidden = true
})
})
} }
@IBAction func onUploadButton(_ sender: Any) { @IBAction func onUploadButton(_ sender: Any) {