Changed UI a bit!

This commit is contained in:
Alexander Munch-hansen 2017-08-01 14:15:59 +02:00
parent dba18dd5d7
commit b56924322c
2 changed files with 67 additions and 39 deletions

View File

@ -21,8 +21,8 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Hej" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wr7-lK-wSY">
<rect key="frame" x="290" y="529" width="26" height="21"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="temp" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wr7-lK-wSY">
<rect key="frame" x="16" y="581" width="150" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
@ -33,38 +33,51 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4gf-ZL-vBk">
<rect key="frame" x="141" y="398" width="93" height="32"/>
<rect key="frame" x="141" y="448" width="93" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Take Photo"/>
<state key="normal" title="Take Photo">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.borderWidth">
<integer key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="onPhotoButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Hsa-47-H63"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hD6-Iz-ohL">
<rect key="frame" x="141" y="438" width="93" height="30"/>
<rect key="frame" x="190" y="410" width="93" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Save Photo"/>
<accessibility key="accessibilityConfiguration" identifier="SaveButton" label="SaveButton"/>
<state key="normal" title="Save Photo">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.borderWidth">
<integer key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="onSaveButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="e6I-Yy-Y5q"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="AIU-y1-LLs">
<rect key="frame" x="39" y="536" width="92" height="30"/>
<rect key="frame" x="141" y="488" width="93" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Photo Library"/>
<state key="normal" title="Library">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.borderWidth">
<integer key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="onLibraryButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="538-4H-pMy"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pq9-PY-U2H">
<rect key="frame" x="162" y="552" width="50" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Upload"/>
<connections>
<action selector="onSaveButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="msf-I0-aFP"/>
<action selector="onUploadButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="rdn-nl-j6f"/>
</connections>
</button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="9YY-rV-nVu">
<rect key="frame" x="39" y="72" width="298" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@ -77,9 +90,24 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</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"/>
<rect key="frame" x="64" y="168" width="247" height="152"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pq9-PY-U2H">
<rect key="frame" x="89" y="410" width="93" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Upload">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.borderWidth">
<integer key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="onUploadButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="rdn-nl-j6f"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>

View File

@ -52,27 +52,6 @@ class ViewController: UIViewController, UINavigationControllerDelegate, UIImageP
func setTextInField(path: String) {
dcavTextField.text = path
}
@IBAction func onSaveButton(_ sender: Any) {
UIImageWriteToSavedPhotosAlbum(imageView.image!, nil, nil, nil);
self.savedPhotoImageView.alpha = 0
self.savedPhotoImageView.isHidden = false
UIView.animate(withDuration: 0.3, delay:0.0, options:UIViewAnimationOptions.transitionCrossDissolve, animations: {
self.savedPhotoImageView.alpha = 1
}, completion: { finished in
UIView.animate(withDuration: 0.3, delay:1, options:UIViewAnimationOptions.transitionCrossDissolve, animations: {
self.savedPhotoImageView.alpha = 0
}, completion: { finished in
self.savedPhotoImageView.isHidden = true
})
})
}
@IBAction func onUploadButton(_ sender: Any) {
guard let username : String = UserDefaults.standard.string(forKey: "username_preference") else {
@ -149,6 +128,27 @@ class ViewController: UIViewController, UINavigationControllerDelegate, UIImageP
return request
}
@IBAction func onSaveButton(_ sender: UIButton) {
UIImageWriteToSavedPhotosAlbum(imageView.image!, nil, nil, nil);
self.savedPhotoImageView.alpha = 0
self.savedPhotoImageView.isHidden = false
UIView.animate(withDuration: 0.3, delay:0.0, options:UIViewAnimationOptions.transitionCrossDissolve, animations: {
self.savedPhotoImageView.alpha = 1
}, completion: { finished in
UIView.animate(withDuration: 0.3, delay:1, options:UIViewAnimationOptions.transitionCrossDissolve, animations: {
self.savedPhotoImageView.alpha = 0
}, completion: { finished in
self.savedPhotoImageView.isHidden = true
})
})
}
//MARK:Update progress bar
func urlSession(_ session: URLSession, task: URLSessionTask, didSendBodyData bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64) {
uploadProgressBar.progress = Float(totalBytesSent) / Float(totalBytesExpectedToSend)