Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewController.swift
- // Animations
- //
- // Created by Andre Oriani on 1/16/17.
- // Copyright © 2017 Orion. All rights reserved.
- //
- import UIKit
- class ViewController: UIViewController {
- @IBOutlet weak var image: UIImageView!
- @IBOutlet weak var image2: UIImageView!
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view, typically from a nib.
- }
- override func viewDidAppear(_ animated: Bool) {
- let animation = CABasicAnimation()
- animation.keyPath = "position.x"
- animation.fromValue = 16
- animation.toValue = 283
- animation.duration = 1
- let animation2 = CABasicAnimation()
- animation2.keyPath = "transform.scale"
- animation2.fromValue = 0.25
- animation2.toValue = 1.2
- animation2.duration = 1
- image.layer.add(animation2, forKey: "teste2")
- let animation3 = CABasicAnimation()
- animation3.keyPath = "opacity"
- animation3.fromValue = 0.2
- animation3.toValue = 1.0
- animation3.duration = 1
- image.layer.add(animation3, forKey: "teste3")
- let animation4 = CABasicAnimation()
- animation4.keyPath = "position"
- animation4.fromValue = CGPoint(x: 16, y: 325)
- animation4.toValue = CGPoint(x: 125, y: 89)
- animation4.duration = 1
- image2.layer.speed = 0
- image2.layer.add(animation4, forKey: "teste4")
- let animation5 = CABasicAnimation()
- animation5.keyPath = "transform.rotation.z"
- animation5.fromValue = 0
- animation5.toValue = 2*3.14
- animation5.duration = 1
- image2.layer.add(animation5, forKey: "teste5")
- image.layer.speed = 0
- image.layer.add(animation, forKey: "teste")
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- @IBAction func sliderValueChanged(_ sender: UISlider) {
- NSLog("Slider \(sender.value)")
- image.layer.timeOffset = CFTimeInterval(sender.value)
- image2.layer.timeOffset = CFTimeInterval(sender.value)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement