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


    }
     
  • 相关阅读:
    Oracle查询错误分析:ORA-01791:不是SELECTed表达式
    Java中DESKeySpec类
    linux发布项目
    mac下搭建cocos2d-x2.2.1版本android编译环境教程
    使用Eigen求解线性方程组
    视觉SLAM十四讲课后答案-ch1
    costmap_2d: obstacle_layer中关于激光雷达障碍物清除不干净的解决
    ch4 激光的前端配准算法一 —— ICP方法
    Project 'cv_bridge' specifies '/usr/include/opencv' as an include dir, which is not found.
    ch3 传感器数据处理II: 激光雷达运动畸变去除
  • 原文地址:https://www.cnblogs.com/tian-sun/p/5038610.html
Copyright © 2011-2022 走看看