diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..53a5d8c Binary files /dev/null and b/.DS_Store differ diff --git a/UIAnimation.xcodeproj/project.pbxproj b/UIAnimation.xcodeproj/project.pbxproj old mode 100644 new mode 100755 index aebf720..1492cdc --- a/UIAnimation.xcodeproj/project.pbxproj +++ b/UIAnimation.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 0C5C9D97229C762900729968 /* ViewControllerBronze.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C5C9D96229C762900729968 /* ViewControllerBronze.swift */; }; + 0C9E14FB229ECD640000F613 /* ViewControllerOuro.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C9E14FA229ECD640000F613 /* ViewControllerOuro.swift */; }; 778CE9D2229BF77300F5483E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 778CE9D1229BF77300F5483E /* AppDelegate.swift */; }; 778CE9D4229BF77300F5483E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 778CE9D3229BF77300F5483E /* ViewController.swift */; }; 778CE9D7229BF77300F5483E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 778CE9D5229BF77300F5483E /* Main.storyboard */; }; @@ -15,6 +17,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 0C5C9D96229C762900729968 /* ViewControllerBronze.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewControllerBronze.swift; sourceTree = ""; }; + 0C9E14FA229ECD640000F613 /* ViewControllerOuro.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewControllerOuro.swift; sourceTree = ""; }; 778CE9CE229BF77300F5483E /* UIAnimation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIAnimation.app; sourceTree = BUILT_PRODUCTS_DIR; }; 778CE9D1229BF77300F5483E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 778CE9D3229BF77300F5483E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -56,7 +60,9 @@ children = ( 778CE9D1229BF77300F5483E /* AppDelegate.swift */, 778CE9D3229BF77300F5483E /* ViewController.swift */, + 0C5C9D96229C762900729968 /* ViewControllerBronze.swift */, 778CE9D5229BF77300F5483E /* Main.storyboard */, + 0C9E14FA229ECD640000F613 /* ViewControllerOuro.swift */, 778CE9D8229BF77600F5483E /* Assets.xcassets */, 778CE9DA229BF77600F5483E /* LaunchScreen.storyboard */, 778CE9DD229BF77600F5483E /* Info.plist */, @@ -136,7 +142,9 @@ buildActionMask = 2147483647; files = ( 778CE9D4229BF77300F5483E /* ViewController.swift in Sources */, + 0C5C9D97229C762900729968 /* ViewControllerBronze.swift in Sources */, 778CE9D2229BF77300F5483E /* AppDelegate.swift in Sources */, + 0C9E14FB229ECD640000F613 /* ViewControllerOuro.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/UIAnimation.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/UIAnimation.xcodeproj/project.xcworkspace/contents.xcworkspacedata old mode 100644 new mode 100755 diff --git a/UIAnimation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/UIAnimation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist old mode 100644 new mode 100755 diff --git a/UIAnimation.xcodeproj/project.xcworkspace/xcuserdata/fabricioguilhermo.xcuserdatad/UserInterfaceState.xcuserstate b/UIAnimation.xcodeproj/project.xcworkspace/xcuserdata/fabricioguilhermo.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..67a62e7 Binary files /dev/null and b/UIAnimation.xcodeproj/project.xcworkspace/xcuserdata/fabricioguilhermo.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/UIAnimation.xcodeproj/xcuserdata/fabricioguilhermo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/UIAnimation.xcodeproj/xcuserdata/fabricioguilhermo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..382bfd7 --- /dev/null +++ b/UIAnimation.xcodeproj/xcuserdata/fabricioguilhermo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/UIAnimation.xcodeproj/xcuserdata/fabricioguilhermo.xcuserdatad/xcschemes/xcschememanagement.plist b/UIAnimation.xcodeproj/xcuserdata/fabricioguilhermo.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..d7d0658 --- /dev/null +++ b/UIAnimation.xcodeproj/xcuserdata/fabricioguilhermo.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + UIAnimation.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/UIAnimation.xcodeproj/xcuserdata/phcacique.xcuserdatad/xcschemes/xcschememanagement.plist b/UIAnimation.xcodeproj/xcuserdata/phcacique.xcuserdatad/xcschemes/xcschememanagement.plist old mode 100644 new mode 100755 diff --git a/UIAnimation/AppDelegate.swift b/UIAnimation/AppDelegate.swift old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/Contents.json b/UIAnimation/Assets.xcassets/AppIcon.appiconset/Contents.json old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-AppStore.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-AppStore.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad20.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad20.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad20@2x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad20@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad29.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad29.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad29@2x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad29@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad40.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad40.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad40@2x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad40@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad76.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad76.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad76@2x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad76@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad83@2x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPad83@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone20@2x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone20@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone20@3x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone20@3x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone29@2x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone29@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone29@3x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone29@3x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone40@2x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone40@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone40@3x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone40@3x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone60@2x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone60@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone60@3x.png b/UIAnimation/Assets.xcassets/AppIcon.appiconset/icon-iPhone60@3x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/Contents.json b/UIAnimation/Assets.xcassets/Contents.json old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon1.imageset/Contents.json b/UIAnimation/Assets.xcassets/icon1.imageset/Contents.json old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon1.imageset/icon1.png b/UIAnimation/Assets.xcassets/icon1.imageset/icon1.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon1.imageset/icon1@2x.png b/UIAnimation/Assets.xcassets/icon1.imageset/icon1@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon1.imageset/icon1@3x.png b/UIAnimation/Assets.xcassets/icon1.imageset/icon1@3x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon2.imageset/Contents.json b/UIAnimation/Assets.xcassets/icon2.imageset/Contents.json old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon2.imageset/icon2@1x.png b/UIAnimation/Assets.xcassets/icon2.imageset/icon2@1x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon2.imageset/icon2@2x.png b/UIAnimation/Assets.xcassets/icon2.imageset/icon2@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon2.imageset/icon2@3x.png b/UIAnimation/Assets.xcassets/icon2.imageset/icon2@3x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon3.imageset/Contents.json b/UIAnimation/Assets.xcassets/icon3.imageset/Contents.json old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon3.imageset/icon3.png b/UIAnimation/Assets.xcassets/icon3.imageset/icon3.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon3.imageset/icon3@2x.png b/UIAnimation/Assets.xcassets/icon3.imageset/icon3@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon3.imageset/icon3@3x.png b/UIAnimation/Assets.xcassets/icon3.imageset/icon3@3x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon4.imageset/Contents.json b/UIAnimation/Assets.xcassets/icon4.imageset/Contents.json old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon4.imageset/icon4@1x.png b/UIAnimation/Assets.xcassets/icon4.imageset/icon4@1x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon4.imageset/icon4@2x.png b/UIAnimation/Assets.xcassets/icon4.imageset/icon4@2x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/icon4.imageset/icon4@3x.png b/UIAnimation/Assets.xcassets/icon4.imageset/icon4@3x.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/rocket.imageset/Contents.json b/UIAnimation/Assets.xcassets/rocket.imageset/Contents.json old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/rocket.imageset/rocket.png b/UIAnimation/Assets.xcassets/rocket.imageset/rocket.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/rocket2.imageset/Contents.json b/UIAnimation/Assets.xcassets/rocket2.imageset/Contents.json old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/rocket2.imageset/rocket2.png b/UIAnimation/Assets.xcassets/rocket2.imageset/rocket2.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/world1.imageset/Contents.json b/UIAnimation/Assets.xcassets/world1.imageset/Contents.json old mode 100644 new mode 100755 diff --git a/UIAnimation/Assets.xcassets/world1.imageset/world1.png b/UIAnimation/Assets.xcassets/world1.imageset/world1.png old mode 100644 new mode 100755 diff --git a/UIAnimation/Base.lproj/LaunchScreen.storyboard b/UIAnimation/Base.lproj/LaunchScreen.storyboard old mode 100644 new mode 100755 diff --git a/UIAnimation/Base.lproj/Main.storyboard b/UIAnimation/Base.lproj/Main.storyboard old mode 100644 new mode 100755 index c20059c..f37563d --- a/UIAnimation/Base.lproj/Main.storyboard +++ b/UIAnimation/Base.lproj/Main.storyboard @@ -13,18 +13,44 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -45,23 +71,52 @@ - + - + + + + + + + + + + + + + + + + + - + - + @@ -79,6 +134,10 @@ + + + + @@ -93,7 +152,7 @@ - + diff --git a/UIAnimation/Info.plist b/UIAnimation/Info.plist old mode 100644 new mode 100755 diff --git a/UIAnimation/ViewController.swift b/UIAnimation/ViewController.swift old mode 100644 new mode 100755 index 9804cbb..f840ba0 --- a/UIAnimation/ViewController.swift +++ b/UIAnimation/ViewController.swift @@ -1,20 +1,65 @@ -// -// ViewController.swift -// UIAnimation_base -// -// Created by Pedro Cacique on 27/05/19. -// Copyright © 2019 Pedro Cacique. All rights reserved. -// +// Animação import UIKit -class ViewController: UIViewController { - - override func viewDidLoad() { +class ViewController: UIViewController +{ + // linkando o foguete e o mundo + @IBOutlet weak var rocket: UIImageView! + @IBOutlet weak var world: UIImageView! + + override func viewDidLoad() + { + print("viewDidLoad") super.viewDidLoad() + } + + + override func viewDidAppear(_ animated: Bool) + { + print("viewDidAppear") + UIView.animate(withDuration: 3.0, delay: 0, options: [.curveEaseInOut], animations: + { + self.rocket.center.y = self.view.frame.height - self.world.frame.height/2 + + self.rocket.transform = self.rocket.transform.rotated(by: .pi/2) +// self.rocket.transform = self.rocket.transform.scaledBy(x: 2, y: 2) + }, completion: // ação executada após o término da animação + { + finished in +// self.rocket.image = UIImage(named: "rocket2.png") + self.outraAnimacao() + }) + } + + func outraAnimacao() + { + UIView.animate(withDuration: 3.0, animations: + { + self.rocket.center.x = self.view.frame.width + self.rocket.frame.width/2 + }) + } + + + override func viewWillAppear(_ animated: Bool) + { + print("viewWillAppear") + // chamada para arrumar o conteúdo antes de aparecer na tela + // .frame = tamanho + + // largura do planeta = largura da view + self.world.frame.size.width = self.view.frame.width + + // posiciona o planeta na parte de baixo + self.world.center.y = self.view.frame.height + // altura do foguete = 15% da altura da view + self.rocket.frame.size.height = self.view.frame.height * 0.15 + + // centralizar no eixo x + self.rocket.center.x = self.view.center.x + + // posiciona o foguete na parte de cima da view + self.rocket.center.y = self.rocket.frame.height/2 } - - } - diff --git a/UIAnimation/ViewControllerBronze.swift b/UIAnimation/ViewControllerBronze.swift new file mode 100644 index 0000000..25ce6a2 --- /dev/null +++ b/UIAnimation/ViewControllerBronze.swift @@ -0,0 +1,111 @@ +// +// ViewControllerBronze.swift +// UIAnimation +// +// Created by Fabrício Guilhermo on 27/05/19. +// Copyright © 2019 Pedro Cacique. All rights reserved. +// +import UIKit + +class ViewControllerBronze: UIViewController +{ + + // segmented control, para trocar background + @IBOutlet weak var segmentedControl: UISegmentedControl! + @IBAction func indexChanged(_ sender: Any) + { + switch segmentedControl.selectedSegmentIndex + { + case 0: + self.view.backgroundColor = #colorLiteral(red: 0.2625385225, green: 0.3625041246, blue: 0.4428519905, alpha: 1) + case 1: + self.view.backgroundColor = #colorLiteral(red: 0.09890385717, green: 0.1375659108, blue: 0.1691181362, alpha: 1) + default: + break + } + } + + + + @IBOutlet weak var rocket: UIImageView! + @IBOutlet weak var world: UIImageView! + + override func viewDidLoad() + { + print("viewDidLoad") + super.viewDidLoad() + } + + + override func viewDidAppear(_ animated: Bool) + { + print("viewDidAppear") + UIView.animate(withDuration: 3, delay: 0, options: [.curveEaseInOut], animations: + { + self.rocket.center.y = -self.view.frame.height + self.view.frame.height - self.rocket.frame.height/2 + }) + } + + + override func viewWillAppear(_ animated: Bool) + { + print("viewWillAppear") + + // chamada para arrumar o conteúdo antes de aparecer na tela + // .frame = tamanho + + // largura do planeta = largura da view + self.world.frame.size.width = self.view.frame.width + + // posiciona o planeta na parte de baixo + self.world.center.y = self.view.frame.height + + // altura do foguete = 15% da altura da view + self.rocket.frame.size.height = self.view.frame.height * 0.35 + + // centralizar no eixo x + self.rocket.center.x = self.view.center.x + + // posiciona o foguete na parte de baixo da view + self.rocket.center.y = self.view.frame.height - self.world.frame.height/2 + + self.view.sendSubviewToBack(rocket) + self.view.sendSubviewToBack(world) + + let myPath = UIBezierPath() + myPath.move(to: CGPoint(x: self.view.center.x, y: self.view.frame.height + self.rocket.frame.height/2)) + myPath.addLine(to: CGPoint(x: self.view.center.x, y: -self.view.frame.height + self.view.frame.height - self.rocket.frame.height)) + + let myShapeLayer = CAShapeLayer() + myShapeLayer.strokeColor = #colorLiteral(red: 0.9439728856, green: 0.6075943708, blue: 0.1707503796, alpha: 1) + myShapeLayer.lineWidth = 6 + + myShapeLayer.path = myPath.cgPath + view.layer.addSublayer(myShapeLayer) + myShapeLayer.zPosition = -1 + myShapeLayer.strokeStart = 0.8 + + let myAnimation = CABasicAnimation(keyPath: "strokeEnd") + myAnimation.fromValue = 0 + myAnimation.toValue = 1 + myAnimation.duration = 1 + + myShapeLayer.add(myAnimation, forKey: "drawLine") + + //Criamos a animação que desenha + let myEndAnimation = CABasicAnimation(keyPath: "strokeEnd") + myEndAnimation.fromValue = 0.2 + myEndAnimation.toValue = 1.0 + + //E em seguida, a que apaga + let myStartAnimation = CABasicAnimation(keyPath: "strokeStart") + myStartAnimation.fromValue = 0.0 + myStartAnimation.toValue = 0.8 + let animationGroup = CAAnimationGroup() + animationGroup.animations = [myStartAnimation, myEndAnimation] + animationGroup.duration = 3 + + myShapeLayer.add(animationGroup, forKey: "drawLine") + view.layer.addSublayer(myShapeLayer) + } +} diff --git a/UIAnimation/ViewControllerOuro.swift b/UIAnimation/ViewControllerOuro.swift new file mode 100644 index 0000000..5fa2a9c --- /dev/null +++ b/UIAnimation/ViewControllerOuro.swift @@ -0,0 +1,29 @@ +// +// ViewControllerOuro.swift +// UIAnimation +// +// Created by Fabrício Guilhermo on 29/05/19. +// Copyright © 2019 Pedro Cacique. All rights reserved. +// + +import UIKit + +class ViewControllerOuro: UIViewController { + + @IBOutlet weak var card: UIView! + @IBOutlet weak var titulo: UILabel! + + @IBAction func openCard(_ sender: Any) + { + UIView.animate(withDuration: 1, delay: 0, options: [.curveEaseInOut], animations: + { + self.card.center.x = self.card.frame.width/2 + self.card.center.y = self.card.frame.height/2 + self.card.frame.size = self.view.frame.size + + self.titulo.center.x = self.view.center.x + self.titulo.center.y = self.titulo.frame.height*2.8 + }) + } + +}