zoukankan      html  css  js  c++  java
  • 2016-01-07 定时器

    #import "timerViewController.h"

     

    @interface timerViewController ()

    {

        NSTimer *timerTaks;

        int  CountdownInt;

        UILabel  *labCountdown;

    }

    @end

     

    @implementation timerViewController

     

    - (void)viewDidLoad {

        [super viewDidLoad];

        self.view.backgroundColor=[UIColor whiteColor];

        CountdownInt=0;

        

        labCountdown=[[UILabel alloc]initWithFrame:CGRectMake(30, 100, 50, 40)];

        labCountdown.backgroundColor=[UIColor yellowColor];

        labCountdown.textColor=[UIColor redColor];

        [self.view addSubview:labCountdown];

        timerTaks = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(CountdownTimeer) userInfo:nil repeats:YES];

    }

     

     

     

     

    -(void)CountdownTimeer

    {

        CountdownInt++;

        if (CountdownInt==60) {

            [timerTaks invalidate];

           

            labCountdown.hidden = YES;

            CountdownInt = 0;

        }else

        {

            labCountdown.text = [NSString stringWithFormat:@"%ds",60-CountdownInt];

            

        }

        

        

        

    }

     

     

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

     

    /*

    #pragma mark - Navigation

     

    // In a storyboard-based application, you will often want to do a little preparation before navigation

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

        // Get the new view controller using [segue destinationViewController].

        // Pass the selected object to the new view controller.

    }

    */

     

    @end

  • 相关阅读:
    Js学习第十天----函数
    IOS Object和javaScript相互调用
    hadoop2.7.1 nutch2.3 二次开发windows环境
    交叉熵代价函数(作用及公式推导)
    推断dxf文件的版本号
    mahout in Action2.2-聚类介绍-K-means聚类算法
    Xcode 技巧充电篇
    Android 推断SD卡是否存在及容量查询
    springmvc学习笔记(12)-springmvc注解开发之包装类型參数绑定
    pip简单配置
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5110686.html
Copyright © 2011-2022 走看看