Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. //
  2. // ViewController.swift
  3. // Animations
  4. //
  5. // Created by Andre Oriani on 1/16/17.
  6. // Copyright © 2017 Orion. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class ViewController: UIViewController {
  12.  
  13. @IBOutlet weak var image: UIImageView!
  14. @IBOutlet weak var image2: UIImageView!
  15.  
  16. override func viewDidLoad() {
  17. super.viewDidLoad()
  18. // Do any additional setup after loading the view, typically from a nib.
  19. }
  20.  
  21. override func viewDidAppear(_ animated: Bool) {
  22. let animation = CABasicAnimation()
  23. animation.keyPath = "position.x"
  24. animation.fromValue = 16
  25. animation.toValue = 283
  26. animation.duration = 1
  27.  
  28. let animation2 = CABasicAnimation()
  29. animation2.keyPath = "transform.scale"
  30. animation2.fromValue = 0.25
  31. animation2.toValue = 1.2
  32. animation2.duration = 1
  33. image.layer.add(animation2, forKey: "teste2")
  34.  
  35. let animation3 = CABasicAnimation()
  36. animation3.keyPath = "opacity"
  37. animation3.fromValue = 0.2
  38. animation3.toValue = 1.0
  39. animation3.duration = 1
  40. image.layer.add(animation3, forKey: "teste3")
  41.  
  42. let animation4 = CABasicAnimation()
  43. animation4.keyPath = "position"
  44. animation4.fromValue = CGPoint(x: 16, y: 325)
  45. animation4.toValue = CGPoint(x: 125, y: 89)
  46. animation4.duration = 1
  47. image2.layer.speed = 0
  48. image2.layer.add(animation4, forKey: "teste4")
  49.  
  50. let animation5 = CABasicAnimation()
  51. animation5.keyPath = "transform.rotation.z"
  52. animation5.fromValue = 0
  53. animation5.toValue = 2*3.14
  54. animation5.duration = 1
  55. image2.layer.add(animation5, forKey: "teste5")
  56.  
  57. image.layer.speed = 0
  58. image.layer.add(animation, forKey: "teste")
  59. }
  60.  
  61. override func didReceiveMemoryWarning() {
  62. super.didReceiveMemoryWarning()
  63. // Dispose of any resources that can be recreated.
  64. }
  65.  
  66.  
  67. @IBAction func sliderValueChanged(_ sender: UISlider) {
  68. NSLog("Slider \(sender.value)")
  69. image.layer.timeOffset = CFTimeInterval(sender.value)
  70. image2.layer.timeOffset = CFTimeInterval(sender.value)
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement