首页 > Web开发 > 详细

做的东西随便上传

时间:2015-07-22 20:28:19      阅读:179      评论:0      收藏:0      [点我收藏+]

技术分享

 

#import "ShowTimeViewController.h"

@interface ShowTimeViewController ()

@property (weak, nonatomic) IBOutlet UIButton *btnBigen;
@property (weak, nonatomic) IBOutlet UILabel *lbShowTime;

@property ( nonatomic ) BOOL isRunning ;

@property ( strong , strong) NSTimer *  curtimer ;

@property ( nonatomic) int  curInt ;

@end

@implementation ShowTimeViewController


- (IBAction)clickBegin:(id)sender {
    if( self.isRunning)
    {
        //  pause
        [self.curtimer invalidate];
        self.isRunning = NO ;
        
        [self.btnBigen setTitle:@"开始" forState:UIControlStateNormal ] ;
    }else
    {
        //  run
        
        self.isRunning = YES ;
        
     self.curtimer =   [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(updateTime) userInfo:nil repeats:YES];
        
        [self.btnBigen setTitle:@"暂停" forState:UIControlStateNormal ] ;
    }
}

-(void) updateTime
{
    self.curInt ++ ;
    
    int  time =  self.curInt ;
    
    
    int min =  time   /( 1000 * 60  ) ;
    int second =  (time - min * 1000 * 60)  /1000  ;
    int ms =  time - min * 1000 * 60 - second * 1000 ;
    
    self.lbShowTime.text = [NSString stringWithFormat:@"%02d:%02d %03d" , min , second , ms];
}


- (IBAction)clickReset:(id)sender {
   // reset
    [self.curtimer invalidate];
    self.isRunning = NO ;
    self.lbShowTime.text = @"00:00 000" ;
    
    
    [self.btnBigen setTitle:@"开始" forState:UIControlStateNormal ] ;
}




- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

 

做的东西随便上传

原文:http://www.cnblogs.com/didiaodexi/p/4668258.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!