6_StopWatch

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了6_StopWatch相关的知识,希望对你有一定的参考价值。

6

//
//  ViewController.swift
//  StopWatch
//
//  Created by ZC on 16/1/9.
//  Copyright © 2016年 ZC. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    var timer = NSTimer()
    
    var time = 0
    
    func increaseTimer() {
        
        time++
        
        timeLabel.text = String(time)
        
    }
    
    @IBOutlet weak var timeLabel: UILabel!
    
    
    @IBAction func play(sender: AnyObject) {
        
        timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("increaseTimer"), userInfo: nil, repeats: true)
        
    }
    
    @IBAction func pause(sender: AnyObject) {
        
        timer.invalidate()
        
    }
    
    @IBAction func stop(sender: AnyObject) {
        
        timer.invalidate()
        
        time = 0
        
        timeLabel.text = "0"
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

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


}

项目:6_StopWatch

以上是关于6_StopWatch的主要内容,如果未能解决你的问题,请参考以下文章

使用Spring freameword core提供的StopWatch统计代码执行时间

stout代码分析之六:Stopwatch

StopWatch任务执行时间监控

StopWatch 监控Java代码运行时间和分析性能

StopWatch的使用

009 StopWatch