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.
        }


    }
     
  • 相关阅读:
    获奖2008年金蝶集团优秀员工感言
    对如何建设一个可运维高可靠的SAAS平台,我终于有了想法!!!
    javaeye站点被ARP攻击有感
    回想过去几年软件业的荒唐事
    也说一种普遍错误使用的LOG方式
    看看国外的本科生能做什么?(Robert Love)
    zz乱码、编码问题详
    查找linux内核支持的usb摄像头列表(UVC万能驱动)
    Greg KroahHartman LDD3 作者,LKN作者,linux driver 开发者,新闻两则,因为过时了所以就放我这个垃圾博客里吧
    zz QEMU 与 Bochs
  • 原文地址:https://www.cnblogs.com/tian-sun/p/5038610.html
Copyright © 2011-2022 走看看