91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

iOS 時間分鐘秒的倒計時

發布時間:2020-04-07 22:03:26 來源:網絡 閱讀:444 作者:大頭狼小鬼 欄目:移動開發

#import "ViewController.h"


@interface ViewController ()

{

    BOOL timeStart;

    NSMutableArray *savaTimeArry;

}

@end


@implementation ViewController


- (void)viewDidLoad {

    [super viewDidLoad];


    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];

    timeStart = YES;


}



- (void)timerFireMethod:(NSTimer *)theTimer

{

    NSCalendar *cal = [NSCalendar currentCalendar];//定義一個NSCalendar對象

    NSDateComponents *endTime = [[NSDateComponents alloc] init];    //初始化目標時間...

    NSDate *today = [NSDate date];    //得到當前時間

    

    NSDate *date = [NSDate dateWithTimeInterval:117000 sinceDate:today];

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

    NSString *dateString = [dateFormatter stringFromDate:date];

    

    static int year;

    static int month;

    static int day;

    static int hour;

    static int minute;

    static int second;

    if(timeStart)

    {//NSDate中取出年月日,時分秒,但是只能取一次

        year = [[dateString substringWithRange:NSMakeRange(0, 4)] intValue];

        month = [[dateString substringWithRange:NSMakeRange(5, 2)] intValue];

        day = [[dateString substringWithRange:NSMakeRange(8, 2)] intValue];

        hour = [[dateString substringWithRange:NSMakeRange(11, 2)] intValue];

        minute = [[dateString substringWithRange:NSMakeRange(14, 2)] intValue];

        second = [[dateString substringWithRange:NSMakeRange(17, 2)] intValue];

        timeStart= NO;

    }

    

    [endTime setYear:year];

    [endTime setMonth:month];

    [endTime setDay:day];

    [endTime setHour:hour];

    [endTime setMinute:minute];

    [endTime setSecond:second];

    NSDate *todate = [cal dateFromComponents:endTime]; //把目標時間裝載入date

    

    //用來得到具體的時差,是為了統一成北京時間

    unsigned int unitFlags = NSYearCalendarUnit| NSMonthCalendarUnit| NSDayCalendarUnit| NSHourCalendarUnit| NSMinuteCalendarUnit| NSSecondCalendarUnit;

    NSDateComponents *d = [cal components:unitFlags fromDate:today toDate:todate options:0];

    NSString *fen = [NSString stringWithFormat:@"%ld", [d minute]];

    NSString *hou = [NSString stringWithFormat:@"%ld",[d hour]];

    if([d hour]<10)

    {

        hou = [NSString stringWithFormat:@"0%ld",[d hour]];

    }

    

    if([d minute] < 10) {

        fen = [NSString stringWithFormat:@"0%ld",[d minute]];

    }

    NSString *miao = [NSString stringWithFormat:@"%ld", [d second]];

    if([d second] < 10) {

        miao = [NSString stringWithFormat:@"0%ld",[d second]];

    }

    

    if([d second] > 0)

    {

        savaTimeArry = [NSMutableArray array];

        NSString *shouTimer= [NSString stringWithFormat:@"%@%@%@",hou,fen,miao];

        NSString *b1= [shouTimer substringWithRange:NSMakeRange(0,1)];

        NSString *b2= [shouTimer substringWithRange:NSMakeRange(1,1)];

        NSString *b3= [shouTimer substringWithRange:NSMakeRange(2,1)];

        NSString *b4= [shouTimer substringWithRange:NSMakeRange(3,1)];

        NSString *b5= [shouTimer substringWithRange:NSMakeRange(4,1)];

        NSString *b6= [shouTimer substringWithRange:NSMakeRange(5,1)];

        [savaTimeArry addObject:b1];

        [savaTimeArry addObject:b2];

        [savaTimeArry addObject:b3];

        [savaTimeArry addObject:b4];

        [savaTimeArry addObject:b5];

        [savaTimeArry addObject:b6];

    

        [self showtimeView];

        

    } else if([d second] == 0)

    {

        

        //計時1分鐘結束,do_something

        

    } else

    {

        [theTimer invalidate];

    }

    

}



- (void)showtimeView

{

    for(int i = 0 ;i <6;i++)

    {

        UIButton *butom = [UIButton buttonWithType:UIButtonTypeCustom];

        butom.frame = CGRectMake(10+10+i*10+2*i+(int)(i/2)*5, 100, 10, 20);

        butom.backgroundColor = [UIColor blackColor];

        [butom setTitle:[savaTimeArry objectAtIndex:i] forState:UIControlStateNormal];

        [butom setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

        butom.titleLabel.font = [UIFont systemFontOfSize:14.0f];

        [self.view addSubview:butom];

    }

}


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

ios
AI

平昌县| 都兰县| 杭锦后旗| 临海市| 吴旗县| 秭归县| 宜都市| 托克托县| 武邑县| 海口市| 杂多县| 临洮县| 乌拉特中旗| 定安县| 宁蒗| 钟祥市| 钟山县| 汉中市| 榆中县| 翁牛特旗| 莆田市| 松滋市| 仙居县| 包头市| 克什克腾旗| 屏边| 益阳市| 厦门市| 齐齐哈尔市| 延吉市| 青河县| 北海市| 门源| 芷江| 蒙城县| 深泽县| 原阳县| 巴彦县| 湘潭市| 天柱县| 江阴市|