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, width: windowWidth, height: 45))
        arrowView.image = UIImage(named: "arrow")
        self.view.addSubview(arrowView)
       
        let ministryView = UIImageView(frame: CGRect(x: windowWidth, y: 110, width: windowWidth, height: 26))
        ministryView.image = UIImage(named: "ministry")
        self.view.addSubview(ministryView)
       
        let addButon = UIButton(frame: CGRect(x: windowWidth, y: 160, width: 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, width: windowWidth, height: 80))
        firstRow.image = UIImage(named: "1st-row")
        self.view.addSubview(firstRow)
       
        let secondRow = UIImageView(frame: CGRect(x: windowWidth, y: 190 + 80 , width: windowWidth, height: 80))
        secondRow.image = UIImage(named: "2nd-row")
        self.view.addSubview(secondRow)
       
        let thirdRow = UIImageView(frame: CGRect(x: windowWidth, y: 190 + 160, width: windowWidth, height: 38))
        thirdRow.image = UIImage(named: "3rd-row")
        self.view.addSubview(thirdRow)
       
        let fourRow = UIImageView(frame: CGRect(x: windowWidth, y: 190 + 240, width: windowWidth, height: 80))
        fourRow.image = UIImage(named: "4th-row")
        self.view.addSubview(fourRow)
       
        let fiveRow = UIImageView(frame: CGRect(x: windowWidth, y: 190 + 320, width: 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, width: 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, width: 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, width: 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, width: 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, width: 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, width: 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, width: 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, width: windowWidth, height: 80)
            }, completion: nil)
  
    }

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


}
 

转载于:https://www.cnblogs.com/tian-sun/p/5038610.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值