zoukankan      html  css  js  c++  java
  • swift

    //
    //  ViewController.swift
    //  songAnimation
    //
    //  Created by su on 15/12/10.
    //  Copyright © 2015年 tian. All rights reserved.
    //

    import UIKit

    class ViewController: UIViewController {

        override func viewDidLoad() {
            super.viewDidLoad()
            let windowWidth = UIScreen.mainScreen().bounds.size.width
            let frameRect = self.view.frame
            //创建背景
            var bacgroundView = UIImageView(frame: frameRect)
            bacgroundView.image = UIImage(named: "background")
            self.view.addSubview(bacgroundView)
           
            let arrowView = UIImageView(frame: CGRect(x: windowWidth, y: 64, windowWidth, height: 45))
            arrowView.image = UIImage(named: "arrow")
            self.view.addSubview(arrowView)
           
            let ministryView = UIImageView(frame: CGRect(x: windowWidth, y: 110, windowWidth, height: 26))
            ministryView.image = UIImage(named: "ministry")
            self.view.addSubview(ministryView)
           
            let addButon = UIButton(frame: CGRect(x: windowWidth, y: 160, windowWidth, height: 28))
            addButon.setImage(UIImage(named: "add-button"), forState: UIControlState.Normal)
            //设置按钮的高亮状态
            addButon.setImage(UIImage(named: "add-button-pressed"), forState: UIControlState.Highlighted)
            self.view.addSubview(addButon)
            //歌曲列表
            let firstRow = UIImageView(frame: CGRect(x: windowWidth, y: 190, windowWidth, height: 80))
            firstRow.image = UIImage(named: "1st-row")
            self.view.addSubview(firstRow)
           
            let secondRow = UIImageView(frame: CGRect(x: windowWidth, y: 190 + 80 , windowWidth, height: 80))
            secondRow.image = UIImage(named: "2nd-row")
            self.view.addSubview(secondRow)
           
            let thirdRow = UIImageView(frame: CGRect(x: windowWidth, y: 190 + 160, windowWidth, height: 38))
            thirdRow.image = UIImage(named: "3rd-row")
            self.view.addSubview(thirdRow)
           
            let fourRow = UIImageView(frame: CGRect(x: windowWidth, y: 190 + 240, windowWidth, height: 80))
            fourRow.image = UIImage(named: "4th-row")
            self.view.addSubview(fourRow)
           
            let fiveRow = UIImageView(frame: CGRect(x: windowWidth, y: 190 + 320, windowWidth, height: 80))
            fiveRow.image = UIImage(named: "5th-row")
            self.view.addSubview(fiveRow)
           
            //启动延时时间
            let initaDelay = 1.0
            //间隔时间
            let stutter = 0.15
            //动画执行
            let duration = 1.1
            //箭头动画
           
            UIView.animateWithDuration(duration, delay: initaDelay, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -> Void in
                //运动闭包
            arrowView.frame = CGRect(x: 0, y: 64, windowWidth, height: 45)
                }, completion: nil)
            //ministry
            UIView.animateWithDuration(duration, delay: initaDelay + 1 * stutter, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -> Void in
                //运动闭包
                ministryView.frame = CGRect(x: 0, y: 110, windowWidth, height: 26)
                }, completion: nil)
           
            //add song
            UIView.animateWithDuration(duration, delay: initaDelay + 2 * stutter, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -> Void in
                //运动闭包
                addButon.frame = CGRect(x: 0, y: 160, windowWidth, height: 45)
                }, completion: nil)
           
            //歌曲列表
           
            UIView.animateWithDuration(duration, delay: initaDelay + 3 * stutter, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -> Void in
                //运动闭包
                firstRow.frame = CGRect(x: 0, y: 190, windowWidth, height: 80)
                }, completion: nil)

            UIView.animateWithDuration(duration, delay: initaDelay + 4 * stutter, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -> Void in
                //运动闭包
                secondRow.frame = CGRect(x: 0, y: 190 + 80, windowWidth, height: 80)
                }, completion: nil)
           
            UIView.animateWithDuration(duration, delay: initaDelay + 5 * stutter, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -> Void in
                //运动闭包
                thirdRow.frame = CGRect(x: 0, y: 190 + 160, windowWidth, height: 80)
                }, completion: nil)
            UIView.animateWithDuration(duration, delay: initaDelay + 6 * stutter, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -> Void in
                //运动闭包
                fourRow.frame = CGRect(x: 0, y: 190 + 240, windowWidth, height: 80)
                }, completion: nil)
            UIView.animateWithDuration(duration, delay: initaDelay + 7 * stutter, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -> Void in
                //运动闭包
                fiveRow.frame = CGRect(x: 0, y: 190 + 320, windowWidth, height: 80)
                }, completion: nil)
      
        }

        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }


    }
     
  • 相关阅读:
    【转】浏览器的渲染:过程与原理
    DOMContentLoaded、ready、load事件的区别
    ES6中export default 与export区别
    require一个node模块什么时候需要加上.default
    【转】函数防抖与函数节流
    【转】JavaScript函数柯里化的一些思考
    【原】javascript笔记之splice和slice这两兄弟为毛这么难记
    【转】JS 的 new 到底是干什么的?
    【原】移动端vue页面点透事件
    【转】用 async/await 来处理异步
  • 原文地址:https://www.cnblogs.com/tian-sun/p/5038610.html
Copyright © 2011-2022 走看看