码迷,mamicode.com
首页 > 其他好文 > 详细

rocket is going up

时间:2017-11-08 21:26:25      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:end   add   ram   copy   uiview   uiimage   control   fun   anim   

//

//  ViewController.swift

//  hustle-mode

//

//  Created by dwang on 08/11/2017.

//  Copyright ? 2017 dwang. All rights reserved.

//

 

import UIKit

import AVFoundation

 

class ViewController: UIViewController {

    @IBOutlet weak var darkBlueBG: UIImageView!

    @IBOutlet weak var powerBtn: UIButton!

    @IBOutlet weak var cloudHolder: UIView!

    @IBOutlet weak var rocket: UIImageView!

    

    @IBOutlet weak var hustleLbl: UILabel!

    

    @IBOutlet weak var onLbl: UILabel!

    

    var player:AVAudioPlayer!

    

    override func viewDidLoad() {

        super.viewDidLoad()

        let path = Bundle.main.path(forResource: "hustle-on", ofType: "mp3")!

        let url = URL(fileURLWithPath:path)

        do{

            player = try AVAudioPlayer(contentsOf: url)

            player.prepareToPlay()

        }catch let error as NSError{

            print(error.description)

        }

        // Do any additional setup after loading the view, typically from a nib.

    }

 

    @IBAction func powerBtnPressed(_ sender: Any) {

        cloudHolder.isHidden = false

        darkBlueBG.isHidden = true

        powerBtn.isHidden = true

        

        player.play()

        UIView.animate(withDuration: 2.3, animations:{

            self.rocket.frame = CGRect(x: 0, y: 20, width: 264, height: 324)

        }){(finished) in

            self.hustleLbl.isHidden = false

            self.onLbl.isHidden = false

        }

        

        

        

    }

 

}

 

rocket is going up

标签:end   add   ram   copy   uiview   uiimage   control   fun   anim   

原文地址:http://www.cnblogs.com/systembighunter/p/7806205.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!