func textFieldDidBeginEditing(textField: UITextField) {
let theWidth = view.frame.size
let theHeight = view.frame.size
if (UIScreen.mainScreen().bounds.height == 568) {
if (textField == self.profielnameTxt) {
UIView.animateWithDuration(0.3, delay: 0.0, options:UIViewAnimationOptions.CurveLinear, animations: {
self.view.center = CGPointMake(theWidth/2, (theHeight/2)-40)
}, completion: {
(finished:Bool) in
})
}
}
}
This is my code. and I keep getting extra arugument 'delay' in call when I try to build it. I am banging my head and searching google all over, but I can't find out where is wrong
Related
I am trying to show a geoJSON polygon on my IOS map app. I'm using Xcode 13.1, SwiftUI and following some tutorials have coded the map which works successfully. I am now trying to use a geoJSON file generated at geojson.io to display a polygon on the map, but so far I have been unsuccessful. I've added some print statements to the code and I can see the geoJSON seems to parse and be decoded fine, but the mapView.addOverlays call doesn't seem to be calling the mapView function (no print).
If someone wouldn't mind having a look at my code below and point me in the right direction or help me figure out what I'm missing, that would be amazing. Many thanks, Berto.
import UIKit
import MapKit
class ViewController: UIViewController {
private let locationManager = CLLocationManager()
private var currentCoordinate: CLLocationCoordinate2D?
#IBOutlet var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
configureLocationServices()
// Do any additional setup after loading the view.
}
//function to check or request access to the users location while using the app
private func configureLocationServices() {
locationManager.delegate = self
let status = CLLocationManager()
if status.authorizationStatus == .notDetermined {
locationManager.requestWhenInUseAuthorization()
} else if status.authorizationStatus == .authorizedWhenInUse {
beginLocationUpdates(locationManager: locationManager)
}
}
//function to set GPS accuracy and continually track location on map
private func beginLocationUpdates(locationManager: CLLocationManager) {
mapView.showsUserLocation = true
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startUpdatingLocation()
}
//function to set the zoomed area of the map around the current location
private func zoomToLatestLocation(with coordinate: CLLocationCoordinate2D) {
let zoomRegion = MKCoordinateRegion(center: coordinate, latitudinalMeters: 1000, longitudinalMeters: 1000)
mapView.setRegion(zoomRegion, animated: true)
}
}
extension ViewController: CLLocationManagerDelegate {
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
print("mapView renderer called")
if overlay is MKPolygon {
let renderer = MKPolygonRenderer(overlay: overlay)
renderer.fillColor = UIColor.red
renderer.strokeColor = UIColor.black
return renderer
}
return MKOverlayRenderer()
}
//function to update users location
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print("did get latest location")
guard let latestLocation = locations.first else { return }
if currentCoordinate == nil {
zoomToLatestLocation(with: latestLocation.coordinate)
print("calling GeoJSON parse function")
mapView.addOverlays(self.parseGeoJSON())
}
currentCoordinate = latestLocation.coordinate
}
func parseGeoJSON() -> [MKOverlay] {
print("started geoJSON parse")
guard let url = Bundle.main.url(forResource: "london", withExtension: "json") else {
fatalError("unable to get geoJSON")
}
print("loaded trail1 geoJSON")
var geoJSON = [MKGeoJSONObject]()
do {
let data = try Data(contentsOf: url)
geoJSON = try MKGeoJSONDecoder().decode(data)
print("decoded geoJSON")
} catch {
fatalError("unable to decode geoJSON")
}
var overlays = [MKOverlay]()
for item in geoJSON {
if let feature = item as? MKGeoJSONFeature {
for geo in feature.geometry {
if let polygon = geo as? MKPolygon {
overlays.append(polygon)
print("appended polygon")
}
}
}
}
print("returning overlays polygon")
return overlays
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
print("the status changed")
if status == .authorizedWhenInUse {
beginLocationUpdates(locationManager: manager)
}
}
}
London.json file generated from geojson.io
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.2581787109375,
51.415481636209535
],
[
-0.078277587890625,
51.36920841344186
],
[
0.1153564453125,
51.46427482966439
],
[
0.13458251953125,
51.586456488215426
],
[
-0.078277587890625,
51.64358968607138
],
[
-0.28701782226562494,
51.613752957501
],
[
-0.336456298828125,
51.50703296721856
],
[
-0.2581787109375,
51.415481636209535
]
]
]
}
}
]
}
You have implemented the mapView delegate's renderer method...
...but you have not declared that your ViewController is also a MKMapViewDelegate...
...so the renderer is not being called.
I would put MKMapViewDelegate in it's own extension, like this:
extension ViewController: MKMapViewDelegate {
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
print("mapView renderer called")
if overlay is MKPolygon {
let renderer = MKPolygonRenderer(overlay: overlay)
renderer.fillColor = UIColor.red
renderer.strokeColor = UIColor.black
return renderer
}
return MKOverlayRenderer()
}
}
...and don't forget to set mapView's delegate to be your ViewController.
Here is my view model:
let loadMoreTrigger = PublishSubject<Void>()
let refreshTrigger = PublishSubject<Void>()
let loading = BehaviorRelay<Bool>(value: false)
let stories = BehaviorRelay<[Story]>(value: [])
var offset = 0
let error = PublishSubject<String>()
let selectedFeedType: BehaviorRelay<FeedType> = BehaviorRelay(value: .best)
override init() {
super.init()
let refreshRequest = loading.asObservable().sample(refreshTrigger).flatMap { loading -> Observable<[Story]> in
if loading {
return Observable.empty()
} else {
self.offset = 0
return self.fetchStories(type: self.selectedFeedType.value, offset: self.offset)
}
}
let loadMoreRequest = loading.asObservable().sample(loadMoreTrigger).flatMap { loading -> Observable<[Story]> in
if loading {
return Observable.empty()
} else {
self.offset += 10
return self.fetchStories(type: self.selectedFeedType.value, offset: self.offset)
}
}
let request = Observable.merge(refreshRequest, loadMoreRequest).share(replay: 1)
let response = request.flatMap { (stories) -> Observable<[Story]> in
request.do(onError: { error in
self.error.onNext(error.localizedDescription)
}).catchError { (error) -> Observable<[Story]> in
Observable.empty()
}
}.share(replay: 1)
Observable.combineLatest(request, response, stories.asObservable()) { request, response, stories in
return self.offset == 0 ? response : stories + response
}.sample(response).bind(to: stories).disposed(by: disposeBag)
Observable.merge(request.map{_ in true}, response.map{_ in false}, error.map{_ in false}).bind(to: loading).disposed(by: disposeBag)
}
Then when i checking loading observer i have false -> true, instead of true -> false. I just don't understand why it happening.
loading.subscribe {
print($0)
}.disposed(by: disposeBag)
In my viewController i call refreshTrigger on viewWillAppear using rx.sentMessage
Here is getFeed function:
func getFeed(type: FeedType, offset: Int) -> Observable<[Story]> {
return provider.rx.request(.getFeed(type: type, offset: offset)).asObservable().flatMap { (response) -> Observable<[Story]> in
do {
let feedResponse = try self.jsonDecoder.decode(BaseAPIResponse<[Story]>.self, from: response.data)
guard let stories = feedResponse.data else { return .error(APIError.requestFailed)}
return .just(stories)
} catch {
return .error(error)
}
}.catchError { (error) -> Observable<[Story]> in
return .error(error)
}
}
Your request and response observables are emitting values at the exact same time. Which one shows up in your subscribe first is undefined.
Specifically, request doesn't emit a value until after the fetch request completes. Try this instead:
Observable.merge(
loadMoreTrigger.map { true },
refreshTrigger.map { true },
response.map { _ in false },
error.map { _ in false }
)
.bind(to: loading)
.disposed(by: disposeBag)
There are lots of other problems in your code but the above answers this specific question.
I want to capture a video through back camera using swiftUI. I can not find the proper solution on on video recording. I implement the code that record video automatically when view is open But I want to start the recording on bottom button click. Can someone please guide me on this.
import SwiftUI
import AVKit
struct RecordingView: View {
#State private var timer = 5
#State private var onComplete = false
#State private var recording = false
var body: some View {
ZStack {
VideoRecordingView(timeLeft: $timer, onComplete: $onComplete, recording: $recording)
VStack {
Button(action: {self.recording.toggle()}, label: {
ZStack {
Circle()
.fill(Color.white)
.frame(width: 65, height: 65)
Circle()
.stroke(Color.white,lineWidth: 2)
.frame(width: 75, height: 75)
}
})
Button(action: {
self.timer -= 1
print(self.timer)
}, label: {
Text("Toggle timer")
})
.foregroundColor(.white)
.padding()
Button(action: {
self.onComplete.toggle()
}, label: {
Text("Toggle completion")
})
.foregroundColor(.white)
.padding()
}
}
}
}
This is For recordingView
struct VideoRecordingView: UIViewRepresentable {
#Binding var timeLeft: Int
#Binding var onComplete: Bool
#Binding var recording: Bool
func makeUIView(context: UIViewRepresentableContext<VideoRecordingView>) -> PreviewView {
let recordingView = PreviewView()
recordingView.onComplete = {
self.onComplete = true
}
recordingView.onRecord = { timeLeft, totalShakes in
self.timeLeft = timeLeft
self.recording = true
}
recordingView.onReset = {
self.recording = false
self.timeLeft = 30
}
return recordingView
}
func updateUIView(_ uiViewController: PreviewView, context: UIViewRepresentableContext<VideoRecordingView>) {
}
}
extension PreviewView: AVCaptureFileOutputRecordingDelegate{
func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) {
print(outputFileURL.absoluteString)
}
}
class PreviewView: UIView {
private var captureSession: AVCaptureSession?
private var shakeCountDown: Timer?
let videoFileOutput = AVCaptureMovieFileOutput()
var recordingDelegate:AVCaptureFileOutputRecordingDelegate!
var recorded = 0
var secondsToReachGoal = 30
var onRecord: ((Int, Int)->())?
var onReset: (() -> ())?
var onComplete: (() -> ())?
init() {
super.init(frame: .zero)
var allowedAccess = false
let blocker = DispatchGroup()
blocker.enter()
AVCaptureDevice.requestAccess(for: .video) { flag in
allowedAccess = flag
blocker.leave()
}
blocker.wait()
if !allowedAccess {
print("!!! NO ACCESS TO CAMERA")
return
}
// setup session
let session = AVCaptureSession()
session.beginConfiguration()
let videoDevice = AVCaptureDevice.default(.builtInWideAngleCamera,
for: .video, position: .front)
guard videoDevice != nil, let videoDeviceInput = try? AVCaptureDeviceInput(device: videoDevice!), session.canAddInput(videoDeviceInput) else {
print("!!! NO CAMERA DETECTED")
return
}
session.addInput(videoDeviceInput)
session.commitConfiguration()
self.captureSession = session
}
override class var layerClass: AnyClass {
AVCaptureVideoPreviewLayer.self
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var videoPreviewLayer: AVCaptureVideoPreviewLayer {
return layer as! AVCaptureVideoPreviewLayer
}
override func didMoveToSuperview() {
super.didMoveToSuperview()
recordingDelegate = self
startTimers()
if nil != self.superview {
self.videoPreviewLayer.session = self.captureSession
self.videoPreviewLayer.videoGravity = .resizeAspect
self.captureSession?.startRunning()
self.startRecording()
} else {
self.captureSession?.stopRunning()
}
}
private func onTimerFires(){
print("🟢 RECORDING \(videoFileOutput.isRecording)")
secondsToReachGoal -= 1
recorded += 1
onRecord?(secondsToReachGoal, recorded)
if(secondsToReachGoal == 0){
stopRecording()
shakeCountDown?.invalidate()
shakeCountDown = nil
onComplete?()
videoFileOutput.stopRecording()
}
}
func startTimers(){
if shakeCountDown == nil {
shakeCountDown = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { [weak self] (timer) in
self?.onTimerFires()
}
}
}
func startRecording(){
captureSession?.addOutput(videoFileOutput)
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let filePath = documentsURL.appendingPathComponent("tempPZDC")
videoFileOutput.startRecording(to: filePath, recordingDelegate: recordingDelegate)
}
func stopRecording(){
videoFileOutput.stopRecording()
print("🔴 RECORDING \(videoFileOutput.isRecording)")
}
}
Modify your code by this
struct VideoRecordingView: UIViewRepresentable {
#Binding var timeLeft: Int
#Binding var onComplete: Bool
#Binding var recording: Bool
func makeUIView(context: UIViewRepresentableContext<VideoRecordingView>) -> PreviewView {
let recordingView = PreviewView()
recordingView.onComplete = {
self.onComplete = true
}
recordingView.onRecord = { timeLeft, totalShakes in
self.timeLeft = timeLeft
self.recording = true
}
recordingView.onReset = {
self.recording = false
self.timeLeft = 30
}
return recordingView
}
func updateUIView(_ uiViewController: PreviewView, context: UIViewRepresentableContext<VideoRecordingView>) {
if recording {
uiViewController.start()
}
}
}
extension PreviewView: AVCaptureFileOutputRecordingDelegate{
func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) {
print(outputFileURL.absoluteString)
}
}
class PreviewView: UIView {
private var captureSession: AVCaptureSession?
private var shakeCountDown: Timer?
let videoFileOutput = AVCaptureMovieFileOutput()
var recordingDelegate:AVCaptureFileOutputRecordingDelegate!
var recorded = 0
var secondsToReachGoal = 30
var onRecord: ((Int, Int)->())?
var onReset: (() -> ())?
var onComplete: (() -> ())?
init() {
super.init(frame: .zero)
var allowedAccess = false
let blocker = DispatchGroup()
blocker.enter()
AVCaptureDevice.requestAccess(for: .video) { flag in
allowedAccess = flag
blocker.leave()
}
blocker.wait()
if !allowedAccess {
print("!!! NO ACCESS TO CAMERA")
return
}
// setup session
let session = AVCaptureSession()
session.beginConfiguration()
let videoDevice = AVCaptureDevice.default(.builtInWideAngleCamera,
for: .video, position: .front)
guard videoDevice != nil, let videoDeviceInput = try? AVCaptureDeviceInput(device: videoDevice!), session.canAddInput(videoDeviceInput) else {
print("!!! NO CAMERA DETECTED")
return
}
session.addInput(videoDeviceInput)
session.commitConfiguration()
self.captureSession = session
}
override class var layerClass: AnyClass {
AVCaptureVideoPreviewLayer.self
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var videoPreviewLayer: AVCaptureVideoPreviewLayer {
return layer as! AVCaptureVideoPreviewLayer
}
override func didMoveToSuperview() {
super.didMoveToSuperview()
recordingDelegate = self
}
func start() {
startTimers()
if nil != self.superview {
self.videoPreviewLayer.session = self.captureSession
self.videoPreviewLayer.videoGravity = .resizeAspect
self.captureSession?.startRunning()
self.startRecording()
} else {
self.captureSession?.stopRunning()
}
}
private func onTimerFires(){
print("🟢 RECORDING \(videoFileOutput.isRecording)")
secondsToReachGoal -= 1
recorded += 1
onRecord?(secondsToReachGoal, recorded)
if(secondsToReachGoal == 0){
stopRecording()
shakeCountDown?.invalidate()
shakeCountDown = nil
onComplete?()
videoFileOutput.stopRecording()
}
}
func startTimers(){
if shakeCountDown == nil {
shakeCountDown = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { [weak self] (timer) in
self?.onTimerFires()
}
}
}
func startRecording(){
captureSession?.addOutput(videoFileOutput)
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let filePath = documentsURL.appendingPathComponent("tempPZDC")
videoFileOutput.startRecording(to: filePath, recordingDelegate: recordingDelegate)
}
func stopRecording(){
videoFileOutput.stopRecording()
print("🔴 RECORDING \(videoFileOutput.isRecording)")
}
}
i just read in stackoverflow i can only concatenate animation with delay, so i tried this here which simply shrinks and then scales the circle again. unfortunately the shrinking doesn't work!? if i comment out the growing, shrinking works...
struct ContentView: View {
#State var scaleImage : CGFloat = 1
var body: some View {
VStack {
Button(action: {
withAnimation(Animation.easeInOut(duration: 1)) {
self.scaleImage = 0.01
}
withAnimation(Animation.easeInOut(duration: 1).delay(1.0)) {
self.scaleImage = 1
}
}) {
Text ("Start animation")
}
Image(systemName: "circle.fill")
.scaleEffect(scaleImage)
}
}
}
Here is possible approach (based on AnimatableModifier). Actually it demonstrates how current animation end can be detected, and performed something - in this case, for your scaling scenario, just initiate reversing.
Simplified & modified your example
struct TestReversingScaleAnimation: View {
#State var scaleImage : CGFloat = 1
var body: some View {
VStack {
Button("Start animation") {
self.scaleImage = 0.01 // initiate animation
}
Image(systemName: "circle.fill")
.modifier(ReversingScale(to: scaleImage) {
self.scaleImage = 1 // reverse set
})
.animation(.default) // now can be implicit
}
}
}
Actually, show-maker here... important comments inline.
Updated for Xcode 13.3 (tested with iOS 15.4)
struct ReversingScale: AnimatableModifier {
var value: CGFloat
private let target: CGFloat
private let onEnded: () -> ()
init(to value: CGFloat, onEnded: #escaping () -> () = {}) {
self.target = value
self.value = value
self.onEnded = onEnded // << callback
}
var animatableData: CGFloat {
get { value }
set { value = newValue
// newValue here is interpolating by engine, so changing
// from previous to initially set, so when they got equal
// animation ended
let callback = onEnded
if newValue == target {
DispatchQueue.main.async(execute: callback)
}
}
}
func body(content: Content) -> some View {
content.scaleEffect(value)
}
}
Original variant (tested with Xcode 11.4 / iOS 13.4)
struct ReversingScale: AnimatableModifier {
var value: CGFloat
private var target: CGFloat
private var onEnded: () -> ()
init(to value: CGFloat, onEnded: #escaping () -> () = {}) {
self.target = value
self.value = value
self.onEnded = onEnded // << callback
}
var animatableData: CGFloat {
get { value }
set { value = newValue
// newValue here is interpolating by engine, so changing
// from previous to initially set, so when they got equal
// animation ended
if newValue == target {
onEnded()
}
}
}
func body(content: Content) -> some View {
content.scaleEffect(value)
}
}
I have UIPageViewController with 5 pages. It's on boarding animated UIViewControllers animations on each page. I researched for days and couldn't find the way to stop animations and reset the page after scroll(page change) occurs.
My UIPageViewController is set up like this:
class BoardingPageViewController: UIPageViewController {
override func viewDidLoad() {
super.viewDidLoad()
dataSource = self
delegate = self
setViewControllers([getStepOne()], direction: .forward, animated: false, completion: nil)
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
func getStepOne() -> BoardView1ViewController {
return storyboard!.instantiateViewController(withIdentifier: "BoardView1") as! BoardView1ViewController
}
func getStepTwo() -> BoardView2ViewController {
return storyboard!.instantiateViewController(withIdentifier: "BoardView2") as! BoardView2ViewController
}
func getStepThree() -> BoardView3ViewController {
return storyboard!.instantiateViewController(withIdentifier: "BoardView3") as! BoardView3ViewController
}
func getStepFour() -> BoardView4ViewController {
return storyboard!.instantiateViewController(withIdentifier: "BoardView4") as! BoardView4ViewController
}
func getStepFive() -> BoardView5ViewController {
return storyboard!.instantiateViewController(withIdentifier: "BoardView5") as! BoardView5ViewController
}
}
extension BoardingPageViewController : UIPageViewControllerDataSource {
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
if viewController.isKind(of: BoardView5ViewController.self) {
// 5 -> 4
return getStepFour()
} else if viewController.isKind(of: BoardView4ViewController.self) {
// 4 -> 3
return getStepThree()
} else if viewController.isKind(of: BoardView3ViewController.self) {
// 3 -> 2
return getStepTwo()
} else if viewController.isKind(of: BoardView2ViewController.self) {
// 2 -> 1
return getStepOne()
} else {
// 0 -> end of the road
return nil
}
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
if viewController.isKind(of: BoardView1ViewController.self) {
// 0 -> 1
return getStepTwo()
} else if viewController.isKind(of: BoardView2ViewController.self) {
// 1 -> 2
return getStepThree()
} else if viewController.isKind(of: BoardView3ViewController.self) {
// 1 -> 2
return getStepFour()
} else if viewController.isKind(of: BoardView4ViewController.self) {
// 1 -> 2
return getStepFive()
} else {
// 2 -> end of the road
return nil
}
}
func presentationCount(for pageViewController: UIPageViewController) -> Int {
return 5
}
func presentationIndex(for pageViewController: UIPageViewController) -> Int {
return 0
}
}
extension BoardingPageViewController : UIPageViewControllerDelegate {
}
And my UIViewControllers are all similar with simple animations. I tried to making this happen with having chainAni value switch to false and call it on ViewDidDisappear. But it doesn't work if page switch happens in the middle of animation.
override func viewDidAppear(_ animated: Bool) {
chainAni = true
ani0()
}
func ani0() {
if chainAni != true {
return
}
UIView.animate(withDuration: 1, delay: 1, animations: {
self.handPic.alpha = 1
}) { (false) in
self.ani1()
}
}
func ani1() {
if chainAni != true {
return
}
UIView.animate(withDuration: 1.5, delay: 1, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: {
self.highlightAction(any: self.handPic)
self.highlightAction(any: self.folderBtn)
}) { (false) in
self.ani2()
}
}
func ani2() {
if chainAni != true {
return
}
UIView.animate(withDuration: 1.5, delay: 1, animations: {
self.unhighlightAction(any: self.handPic)
self.unhighlightAction(any: self.folderBtn)
}) { (false) in
self.ani3()
}
}
func ani3() {
if chainAni != true {
return
}
UIView.animate(withDuration: 0.5, delay: 0, animations: {
self.handPic.alpha = 0
self.alertImg.alpha = 1
self.alertImg.transform = .identity
}) { (false) in
self.ani4()
}
}
func clearAni() {
alertImg.image = #imageLiteral(resourceName: "alert1")
darkView.removeFromSuperview()
screenView.removeFromSuperview()
mainImg.alpha = 1
alertImg.alpha = 0
alert2Img.alpha = 0
handPic.alpha = 0
handPic.transform = .identity
hand2Pic.alpha = 0
hand2Pic.transform = .identity
newFolderImg.alpha = 0
newFolderImg.transform = .identity
}
override func viewDidDisappear(_ animated: Bool) {
clearAni()
chainAni = false
}
So, I figured I have to remove every animation from it's superview layer.
func clearAni() {
alertImg.image = #imageLiteral(resourceName: "alert1")
mainImg.layer.removeAllAnimations()
mainLbl.layer.removeAllAnimations()
alertImg.layer.removeAllAnimations()
alert2Img.layer.removeAllAnimations()
folderBtn.layer.removeAllAnimations()
handPic.layer.removeAllAnimations()
hand2Pic.layer.removeAllAnimations()
darkView.layer.removeAllAnimations()
mainImg.alpha = 1
alertImg.alpha = 0
alert2Img.alpha = 0
handPic.alpha = 0
handPic.transform = .identity
hand2Pic.alpha = 0
hand2Pic.transform = .identity
newFolderImg.alpha = 0
newFolderImg.transform = .identity
}