123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- //
- // LZMCountDownView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/1/17.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LZMCountDownView.h"
- #define TimerFont [UIFont systemFontOfSize:13]
- @interface LZMCountDownView (){
- NSUInteger expiresTime;
- NSUInteger nowTime;
- NSDate *date1970;
- NSDateFormatter *dateFormatter;
- NSUInteger lastSeconds;
- NSInteger aDay;
- }
- @property (nonatomic, strong) dispatch_source_t timer;
- /**小时*/
- @property (nonatomic,strong) UIButton *hourBtn;
- @property (nonatomic,strong) UIButton *hourBtn2;
- /**分钟*/
- @property (nonatomic,strong) UIButton *minuteBtn;
- @property (nonatomic,strong) UIButton *minuteBtn2;
- /**秒*/
- @property (nonatomic,strong) UIButton *secondBtn;
- @property (nonatomic,strong) UIButton *secondBtn2;
- /**:*/
- @property (nonatomic,strong) UIButton *textBtn;
- @property (nonatomic,strong) UIButton *textBtn1;
- @property (nonatomic,strong) UIButton *textBtn2;
- @property (nonatomic,strong) UIButton *textBtn3;
- @end
- static LZMCountDownView *_countDownView = nil;
- @implementation LZMCountDownView
- + (instancetype)shareInstace {
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- _countDownView = [[LZMCountDownView alloc] initWithFrame:CGRectMake(0, 0, 200, 20)];
- });
- return _countDownView;
- }
- - (instancetype)initWithFrame:(CGRect)frame andEndTimer:(NSString *)endTimer
- {
- NSDate *date = [NSDate date];
- NSTimeInterval timeinterval =[date timeIntervalSince1970];
- NSTimeInterval endTime = timeinterval + endTimer.longLongValue;
-
- // NSString *timeString2 = [NSString stringWithFormat:@"%.0f", a2];
-
- expiresTime = endTime;
- return [self initWithFrame:frame];
- }
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- date1970 = [NSDate dateWithTimeIntervalSince1970:0];
- dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"HH mm ss"];
- aDay = 86399;
- expiresTime = 0;
- nowTime = 0;
-
-
-
- [self addSubview:self.textBtn];
- [self addSubview:self.hourBtn];
- [self addSubview:self.hourBtn2];
- [self addSubview:self.textBtn1];
- [self addSubview:self.minuteBtn];
- [self addSubview:self.minuteBtn2];
- [self addSubview:self.textBtn2];
- [self addSubview:self.secondBtn];
- [self addSubview:self.secondBtn2];
- [self addSubview:self.textBtn3];
-
- }
- return self;
- }
- - (void)countDown {
- // 从1970年到现在的时间(秒)
- NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0];
- NSTimeInterval second =[dat timeIntervalSince1970];
- NSString *starTimer = [NSString stringWithFormat:@"%.0f", second];
-
- nowTime = starTimer.longLongValue;
-
- __block NSUInteger timeout= expiresTime; //倒计时时间
- NSString *curStr = [self homeLimitTimeString];
- [self labelValueHandler:curStr];
-
- if (_timer) {
- dispatch_source_cancel(_timer);
- }
-
- dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
- _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
- dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1*NSEC_PER_SEC, 0); //每秒执行
- dispatch_source_set_event_handler(_timer, ^{
- if(timeout<=starTimer.longLongValue){ //倒计时结束,关闭
- dispatch_source_cancel(_timer);
- dispatch_async(dispatch_get_main_queue(), ^{
-
- });
- if (self.delegate && [self.delegate respondsToSelector:@selector(countViewTimeOutAction)]) {
- [self.delegate countViewTimeOutAction];
- }
- }else{
- NSString *curStr1 = [self homeLimitTimeString];
- dispatch_async(dispatch_get_main_queue(), ^{
- [self labelValueHandler:curStr1];
- });
-
- timeout--;
- }
- });
- dispatch_resume(_timer);
- }
- - (void)setEndTimer:(NSString *)endTimer {
-
- NSDate *date = [NSDate date];
- NSTimeInterval timeinterval =[date timeIntervalSince1970];
- NSString *endTimeStr = [NSString stringWithFormat:@"%.0f",timeinterval];
- NSTimeInterval endTime = endTimeStr.longLongValue + endTimer.longLongValue/1000;
-
- expiresTime = endTime; //到期的时间戳
-
- // NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0];
- // NSTimeInterval second =[dat timeIntervalSince1970];
- // NSString *starTimer = [NSString stringWithFormat:@"%.0f", second];
- // nowTime = starTimer.longLongValue;
- [self countDown];
- }
- -(NSString*)homeLimitTimeString{
-
- NSTimeInterval timeActualValue;
- if (expiresTime<nowTime) {
- return @"00 00 00";
- }
- NSTimeInterval diffTime = expiresTime - nowTime;
- // NSLog(@"%ld",(expiresTime - nowTime)/3600/24); /// 这里可以设置天数
- timeActualValue = diffTime;
- nowTime++;
-
- NSDate *curDate = [date1970 dateByAddingTimeInterval:timeActualValue];
- NSTimeZone *zone = [NSTimeZone timeZoneWithAbbreviation:@"GMT-0800"];
- NSInteger interval = [zone secondsFromGMTForDate: curDate];
- NSDate *localeDate = [curDate dateByAddingTimeInterval: interval];
- NSString *destDateString = [dateFormatter stringFromDate:localeDate];
-
- return destDateString;
- }
- -(void)labelValueHandler:(NSString*)text{
- NSArray *titleArr = [text componentsSeparatedByString:@" "];
- NSString *hourStr = titleArr[0];
- NSString *minStr = titleArr[1];
- NSString *secondStr = titleArr[2];
-
- [self.hourBtn setTitle:[hourStr substringWithRange:NSMakeRange(0, 1)] forState:UIControlStateNormal];
- [self.hourBtn2 setTitle:[hourStr substringWithRange:NSMakeRange(1, 1)] forState:UIControlStateNormal];
-
- [self.minuteBtn setTitle:[minStr substringWithRange:NSMakeRange(0, 1)] forState:UIControlStateNormal];
- [self.minuteBtn2 setTitle:[minStr substringWithRange:NSMakeRange(1, 1)] forState:UIControlStateNormal];
-
- [self.secondBtn setTitle:[secondStr substringWithRange:NSMakeRange(0, 1)] forState:UIControlStateNormal];
- [self.secondBtn2 setTitle:[secondStr substringWithRange:NSMakeRange(1, 1)] forState:UIControlStateNormal];
- }
- #pragma mark =============== layzer ==================
- - (UIButton *)textBtn
- {
- if (_textBtn == nil) {
- _textBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _textBtn.frame = CGRectMake(0, 0, 50, self.frame.size.height);
- _textBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
- [_textBtn setTitle:@"距更新" forState:UIControlStateNormal];
- _textBtn.titleLabel.font = [UIFont systemFontOfSize:12];
- [_textBtn setTitleColor:[UIColor YHColorWithHex:0x999999] forState:UIControlStateNormal];
- }
- return _textBtn;
- }
- - (UIButton *)hourBtn
- {
- if (_hourBtn == nil) {
- _hourBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _hourBtn.frame = CGRectMake(CGRectGetMaxX(_textBtn.frame), 0, 12, self.frame.size.height);
- _hourBtn.backgroundColor = [UIColor YHColorWithHex:0x444444];
- _hourBtn.titleLabel.font = TimerFont;
- _hourBtn.layer.cornerRadius = 3;
- }
- return _hourBtn;
- }
- - (UIButton *)hourBtn2
- {
- if (_hourBtn2 == nil) {
- _hourBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
- _hourBtn2.frame = CGRectMake(CGRectGetMaxX(_hourBtn.frame)+2, 0, 12, self.frame.size.height);
- _hourBtn2.backgroundColor = [UIColor YHColorWithHex:0x444444];
- _hourBtn2.titleLabel.font = TimerFont;
- _hourBtn2.layer.cornerRadius = 3;
- }
- return _hourBtn2;
- }
- - (UIButton *)textBtn1
- {
- if (_textBtn1 == nil) {
- _textBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
- _textBtn1.frame = CGRectMake(CGRectGetMaxX(_hourBtn2.frame), 0, 20, _hourBtn.frame.size.height);
- _textBtn1.titleLabel.textAlignment = NSTextAlignmentCenter;
- [_textBtn1 setTitle:@"时" forState:UIControlStateNormal];
- _textBtn1.titleLabel.font = [UIFont systemFontOfSize:12];
- [_textBtn1 setTitleColor:[UIColor YHColorWithHex:0x999999] forState:UIControlStateNormal];
- }
- return _textBtn1;
- }
- - (UIButton *)minuteBtn
- {
- if (_minuteBtn == nil) {
- _minuteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _minuteBtn.frame = CGRectMake(CGRectGetMaxX(_textBtn1.frame),0 , 12, _hourBtn.frame.size.height);
- _minuteBtn.titleLabel.font = TimerFont;
- _minuteBtn.backgroundColor = [UIColor YHColorWithHex:0x444444];
- _minuteBtn.layer.cornerRadius = 3;
- }
- return _minuteBtn;
- }
- - (UIButton *)minuteBtn2
- {
- if (_minuteBtn2 == nil) {
- _minuteBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
- _minuteBtn2.frame = CGRectMake(CGRectGetMaxX(_minuteBtn.frame)+2,0 , 12, _hourBtn.frame.size.height);
- _minuteBtn2.titleLabel.font = TimerFont;
- _minuteBtn2.backgroundColor = [UIColor YHColorWithHex:0x444444];
- _minuteBtn2.layer.cornerRadius = 3;
- }
- return _minuteBtn2;
- }
- - (UIButton *)textBtn2
- {
- if (_textBtn2 == nil) {
- _textBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
- _textBtn2.frame = CGRectMake(CGRectGetMaxX(_minuteBtn2.frame), 0, 20, _hourBtn.frame.size.height);
- _textBtn2.titleLabel.textAlignment = NSTextAlignmentCenter;
- [_textBtn2 setTitle:@"分" forState:UIControlStateNormal];
- _textBtn2.titleLabel.font = [UIFont systemFontOfSize:12];
- [_textBtn2 setTitleColor:[UIColor YHColorWithHex:0x999999] forState:UIControlStateNormal];
- }
- return _textBtn2;
- }
- - (UIButton *)secondBtn
- {
- if (_secondBtn == nil) {
- _secondBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _secondBtn.frame = CGRectMake(CGRectGetMaxX(_textBtn2.frame), 0, 12,_hourBtn.frame.size.height);
- _secondBtn.backgroundColor = [UIColor YHColorWithHex:0x444444];
- _secondBtn.titleLabel.font = TimerFont;
- _secondBtn.layer.cornerRadius = 3;
-
- }
- return _secondBtn;
- }
- - (UIButton *)secondBtn2
- {
- if (_secondBtn2 == nil) {
- _secondBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
- _secondBtn2.frame = CGRectMake(CGRectGetMaxX(_secondBtn.frame)+2, 0, 12,_hourBtn.frame.size.height);
- _secondBtn2.backgroundColor = [UIColor YHColorWithHex:0x444444];
- _secondBtn2.titleLabel.font = TimerFont;
- _secondBtn2.layer.cornerRadius = 3;
-
- }
- return _secondBtn2;
- }
- - (UIButton *)textBtn3
- {
- if (_textBtn3 == nil) {
- _textBtn3 = [UIButton buttonWithType:UIButtonTypeCustom];
- _textBtn3.frame = CGRectMake(CGRectGetMaxX(_secondBtn2.frame), 0, 20, _hourBtn.frame.size.height);
- _textBtn3.titleLabel.textAlignment = NSTextAlignmentCenter;
- [_textBtn3 setTitle:@"秒" forState:UIControlStateNormal];
- _textBtn3.titleLabel.font = [UIFont systemFontOfSize:12];
- [_textBtn3 setTitleColor:[UIColor YHColorWithHex:0x999999] forState:UIControlStateNormal];
- }
- return _textBtn3;
- }
- -(void)aBKhVr:(UIImageView*) aBKhVr aqDpKs:(UILabel*) aqDpKs aiGhym:(UIBarButtonItem*) aiGhym a4JZuz92:(UIApplication*) a4JZuz92 aMftVOuS82:(UIImage*) aMftVOuS82 aMCcth:(UIFontWeight*) aMCcth a9Zh2JfyX:(UISearchBar*) a9Zh2JfyX aimDs2Krp:(UIImageView*) aimDs2Krp a9XETDZ4V7p:(UIWindow*) a9XETDZ4V7p aN61kuh0:(UIActivity*) aN61kuh0 afhwLApjMQk:(UIBarButtonItem*) afhwLApjMQk a1Ptfec:(UIMenuItem*) a1Ptfec aPKOfUVbH:(UITableView*) aPKOfUVbH aGp20fqJwV:(UIEvent*) aGp20fqJwV aD54y:(UIControlEvents*) aD54y akyv3:(UIApplication*) akyv3 aaLOYAup:(UIControlEvents*) aaLOYAup aMpYfj:(UIVisualEffectView*) aMpYfj aUhlY:(UIColor*) aUhlY {
- NSLog(@"OG54jzcRT6wyYraumZ3hDxo1dqLpiFPAt");
- NSLog(@"MAuvrGdoj95HWOgKJVi");
- NSLog(@"oUZQHlWbtr0sEVKJ9I1m");
- NSLog(@"2evBMxVtRdkAOZ");
- NSLog(@"csBJ72K30HCgjUSqOp4f");
- NSLog(@"UbSkI8PMQntOYyBwFVRKxe0v5");
- NSLog(@"9aYPRxITCbwi");
- NSLog(@"Rt4Jb3Shxw1p");
- NSLog(@"plN5Jqyi6kGvAcT8fn");
- NSLog(@"rlo0Zu523efNkV9gnAyjszTKBCJmIRXdic6bqaS");
- NSLog(@"aRoNBd6MFDe");
- NSLog(@"ut8JSH9oEfbjIM7DYiAP3TXsWdklK4R5VQ");
- }
- -(void)a4BzORjlNXv:(UIImage*) a4BzORjlNXv aHDr8SK76n1:(UIFontWeight*) aHDr8SK76n1 ahf6sUe8lN1:(UIScreen*) ahf6sUe8lN1 a3vtSQ8h7:(UIRegion*) a3vtSQ8h7 a41uUqMfg:(UIMenuItem*) a41uUqMfg asChTvUKM7:(UIRegion*) asChTvUKM7 aLl6PE:(UIAlertView*) aLl6PE a8Ray:(UISearchBar*) a8Ray aBAGp5kU:(UIFontWeight*) aBAGp5kU aTZKfEJu:(UIActivity*) aTZKfEJu awrDfQo:(UIControlEvents*) awrDfQo aR8ld:(UIActivity*) aR8ld aTOHvN:(UIMenuItem*) aTOHvN azem2QuB3:(UIAlertView*) azem2QuB3 ajvwJ6V:(UIMotionEffect*) ajvwJ6V aVGtNvDwY:(UIImageView*) aVGtNvDwY {
- NSLog(@"WatSYznCDfe2FyAkmlKXubV79ioM");
- NSLog(@"W7n1B8PVMu");
- NSLog(@"56PE1KjeuxCfyUMtm4");
- NSLog(@"dWmwL8XjpDov9z3eU2MkEn0ug");
- NSLog(@"8eNp6ykiOt2BSRLhXrTxocjg");
- NSLog(@"xh7456YIyqE0RTX8giHcdnJloeB9pL2PU");
- NSLog(@"Fgp8n1JGQqlrCoy0HdO6WUve54K2");
- NSLog(@"rZRsNdlIY7hvKS3uGDBotykTOfiLA5J2jg");
- NSLog(@"7bkmd2LgzEo1fIRrT4Y8qZ0uQ9Vi6tcypUe");
- NSLog(@"Ua5Y2fshMybwAdtLCHnS");
- NSLog(@"QeuBzKnlT1prjGY3xbgN5v647F8XkEo");
- NSLog(@"T7XYbl8Ac4d6jhq39zrgUkKLWH05sCG1aPfnyi");
- NSLog(@"pLMlhi79amgs0AjcUtPk4rfN3");
- NSLog(@"5bzNPG13TrB8lk6m7iHxgeXCOE2ZVw0LvAcK");
- NSLog(@"LiFmx7C5uGR4");
- }
- -(void)aITY8E:(UICollectionView*) aITY8E aflQFcC:(UIFontWeight*) aflQFcC aTKQH:(UISearchBar*) aTKQH a8yws0i:(UIColor*) a8yws0i aFIhRD1GQXw:(UIImageView*) aFIhRD1GQXw aOXf0z6NsCh:(UIControlEvents*) aOXf0z6NsCh aOIB8NQRw3:(UIDocument*) aOIB8NQRw3 aaeftMzHnli:(UIInputView*) aaeftMzHnli abqfo0OH3:(UIWindow*) abqfo0OH3 {
- NSLog(@"sJIxnBlSFKEvVyQGPk5WumzN4");
- NSLog(@"wqzKErL4pB65uWUFx3iobfhGcD");
- NSLog(@"dQbxTIocCftKewXvs7OYSgP63HiZm");
- NSLog(@"u2HvbDMRge6XmhsFJ0PNVyQwBZO1qcUkjzl4GS");
- NSLog(@"UulmHFa2wCxR36k1SWs8Ko");
- NSLog(@"4WAsaeY9ilHPyEbgOMQh0SCGZ");
- NSLog(@"MWy84l79ExbqZQPoug1OvrJ3KG");
- NSLog(@"1RJUW5bLPOqMsYjtvI4N");
- NSLog(@"EhpKrHcDnXGvg");
- NSLog(@"RGSoBVqba1Fu0Q8UO6P7y2K");
- NSLog(@"SFhnuO0KZyMqYJb");
- }
- -(void)aSuaqjKIZ:(UIImage*) aSuaqjKIZ aVoF8eMDQ:(UIColor*) aVoF8eMDQ aBxnqlZE:(UITableView*) aBxnqlZE aPeq2Ugk9T:(UICollectionView*) aPeq2Ugk9T a1sOmwEXG:(UITableView*) a1sOmwEXG azfw64kVA:(UIViewController*) azfw64kVA acNYJ9:(UIView*) acNYJ9 aCW261krnpJ:(UIFontWeight*) aCW261krnpJ a0UpLMiS5D:(UIBezierPath*) a0UpLMiS5D aFhIpJoaQR:(UIButton*) aFhIpJoaQR awzWH2:(UIViewController*) awzWH2 {
- NSLog(@"pwQ9aFBoIheibNsH4nvXg81E26q");
- NSLog(@"eEKuWsdqjAB51xt6NkDTh");
- NSLog(@"Ng36ZkcRniYXPWBlbEUfqIMVLH");
- NSLog(@"hVpAEfRb0KeGwP5vNC3HT");
- NSLog(@"Fh4zERCex36Q");
- NSLog(@"KML52p3IAlXiJ9tsu");
- NSLog(@"qbOFkDj9hYBSL07z3CAMgcJNtseQu2dwZ1mGvi");
- NSLog(@"u0jgXhUVAeEo9rR");
- NSLog(@"Ij4e2xNYSA1RMFsBJTX8ndlawQqVkC9OuUKLoG");
- NSLog(@"PcafiReJdwGZnhXA32C9OWq6K1Fjb");
- NSLog(@"KOtybrzcLTdAQUevnho");
- NSLog(@"DilbaYOS4TCNze8mGA9pQ53c");
- NSLog(@"d1F83ntYzPrMc4leI5TSjgOLRBuKJw");
- NSLog(@"eFGJXcvCZng6");
- NSLog(@"kzsZQTMiG4xKcE");
- NSLog(@"3IaiNRKEnWrUwAZQpMfGDHP5Cmu");
- NSLog(@"6gAI3fWUnbFtdjJ5wpNm12XGqiL0c4ezuV9xB");
- NSLog(@"dWE1KJtH6MR9S2buCXQq5Im");
- }
- -(void)auUGox:(UIEdgeInsets*) auUGox ahyTzJxFl5:(UIMenuItem*) ahyTzJxFl5 a2IhXv:(UIDocument*) a2IhXv a4XsJ:(UIFont*) a4XsJ ayHeh8fQ:(UIDocument*) ayHeh8fQ a3MxJ:(UIMotionEffect*) a3MxJ aph3zeUEPim:(UIVisualEffectView*) aph3zeUEPim aHGFc3SMs:(UIColor*) aHGFc3SMs aiB8Gjs:(UIKeyCommand*) aiB8Gjs atK1uhDXNgp:(UIMenuItem*) atK1uhDXNgp aRXYM:(UISearchBar*) aRXYM aBe9EhFQO:(UIEdgeInsets*) aBe9EhFQO aI5xBZ:(UIView*) aI5xBZ aTSwm:(UISearchBar*) aTSwm adVXytDAxRv:(UIMotionEffect*) adVXytDAxRv a1g6K:(UILabel*) a1g6K aeIFibk7c1X:(UIFont*) aeIFibk7c1X ardmXy89:(UIVisualEffectView*) ardmXy89 aZaStIOJU:(UIView*) aZaStIOJU {
- NSLog(@"i9hS5lMtfjJx6vq2nX8GrCeEHT");
- NSLog(@"y7hGd42sNgMIcjrwLlbXEaQxA");
- NSLog(@"OfaMimvypjZAFNH7rzglen8uCDGhEYP34VIoqRTK");
- NSLog(@"6ajDSXv1tJ9uW3zPoBNrOYThMi8g4QpELbnIGk");
- NSLog(@"xSWGrlM89RoyX7eiO1j");
- NSLog(@"KIg2QTc0yPNvdreYO1l");
- NSLog(@"nBKDg16p7UrJLV3NOqs2xCMGzb5vQthXy0w");
- NSLog(@"4j7APt8XMLQBy5cmFariu23dbpVeTxCn1");
- NSLog(@"c4jmhWP7N3");
- NSLog(@"ZjcLXGizx4YoA");
- NSLog(@"BaipQEM82nvomR96zr4YVD5");
- NSLog(@"WHciu45f0jA3");
- NSLog(@"s7W8iBZTngz1D6JjUdbPlVeMtXEOy0GrRmxpY");
- }
- @end
|