Commit 93cfbaff cgx

修复倒计时显示问题

1 个父辈 2a30144c
......@@ -1094,8 +1094,6 @@
D0C50B3E27FD381000DC68F0 /* UIView+Extras.m */,
D027EE2E27FB52DA004BBA61 /* UIImage+Extras.h */,
D027EE2F27FB52DA004BBA61 /* UIImage+Extras.m */,
D0C50B4027FD39C800DC68F0 /* UIViewController+FullScreenModal.h */,
D0C50B4127FD39C800DC68F0 /* UIViewController+FullScreenModal.m */,
D0F80905280431100097899F /* UILabel+Extras.h */,
D0F80906280431100097899F /* UILabel+Extras.m */,
D0506B0A280503A800229278 /* UIButton+Extras.h */,
......@@ -1110,6 +1108,8 @@
D0A245F5283DB12100FB49AA /* WKWebView+Extras.m */,
D05416F5288A57BD0035060B /* AVAudioSession+SXAudioSession.h */,
D05416F6288A57BD0035060B /* AVAudioSession+SXAudioSession.m */,
D0C50B4027FD39C800DC68F0 /* UIViewController+FullScreenModal.h */,
D0C50B4127FD39C800DC68F0 /* UIViewController+FullScreenModal.m */,
);
path = Category;
sourceTree = "<group>";
......@@ -1570,14 +1570,14 @@
D0AE1E3428281B6F008CEF27 /* TimerProxy.m */,
D0C50B4427FD66FB00DC68F0 /* DSConstUtil.h */,
D0C50B4527FD66FB00DC68F0 /* DSConstUtil.m */,
D0B5ECC627F2E97A003EDFE3 /* MacroFuncUtil.h */,
D0B5ECC727F2E97A003EDFE3 /* MacroFuncUtil.m */,
D043A8BA287EC71400226176 /* RingingTools.h */,
D043A8BB287EC71400226176 /* RingingTools.m */,
D0B5ECD627F2F1B0003EDFE3 /* ServerAPIUtil.h */,
D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */,
D0B5ECD327F2F0B2003EDFE3 /* AdaptationUtil.h */,
D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */,
D0B5ECC627F2E97A003EDFE3 /* MacroFuncUtil.h */,
D0B5ECC727F2E97A003EDFE3 /* MacroFuncUtil.m */,
);
path = Utils;
sourceTree = "<group>";
......
......@@ -34,6 +34,10 @@ NS_ASSUME_NONNULL_BEGIN
/// 转义特殊字符
/// @param oriStr oriStr
+ (NSString *)transferSpecialCharacters:(NSString *)oriStr;
/// 获取格式化时间
/// @param time time(单位:s)
+ (NSString *)getFormatTime:(NSInteger)time;
@end
NS_ASSUME_NONNULL_END
......@@ -54,4 +54,10 @@
return @"";
}
+ (NSString *)getFormatTime:(NSInteger)time {
NSInteger minutes = time / 60;
NSInteger seconds = time % 60;
return [NSString stringWithFormat:@"%02ld:%02ld", minutes, seconds];
}
@end
......@@ -83,25 +83,10 @@
return;
}
_countTime--;
NSString *countDownStr = [self formattimewithtimeinterval:_countTime];
_percentLabel.text = [NSString stringWithFormat:@"%@", countDownStr];
_percentLabel.text = [NSString getFormatTime:_countTime];
_circle.progress = (double)(_totalTime - _countTime)/(double)(_totalTime);
}
- (NSString *)formattimewithtimeinterval:(NSTimeInterval)timeinterval {
int minute = 0, hour = 0, secend = timeinterval;
minute = (secend % 3600)/60;
hour = secend / 3600;
secend = secend % 60;
if (hour == 0) {
return [NSString stringWithFormat:@"%02d:%02d", minute, secend];
} else if (minute == 0){
return [NSString stringWithFormat:@"%02d", secend];
} else {
return [NSString stringWithFormat:@"%02d:%02d:%02d", hour, minute, secend];
}
}
#pragma mark - Setter
- (void)setProgress:(float)progress {
_progress = progress;
......
......@@ -38,8 +38,8 @@
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)]) {
self.minuteIndex = 0;
self.countTime = 60;
self.minuteIndex = 19;
self.countTime = 60*20;
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self buildInterface];
......@@ -123,7 +123,7 @@
[self.timeCloseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.mas_bottom).offset(-36);
make.right.equalTo(self.mas_right).offset(-23);
make.width.equalTo(@80);
make.width.equalTo(@100);
make.height.equalTo(@60);
}];
}
......@@ -241,21 +241,6 @@
return self.playModeBtn.tag;
}
#pragma mark - others
- (NSString *)formattimewithtimeinterval:(NSTimeInterval)timeinterval {
int minute = 0, hour = 0, secend = timeinterval;
minute = (secend % 3600)/60;
hour = secend / 3600;
secend = secend % 60;
if (hour == 0) {
return [NSString stringWithFormat:@"%02d:%02d", minute, secend];
} else if (minute == 0){
return [NSString stringWithFormat:@"%02d", secend];
} else {
return [NSString stringWithFormat:@"%02d:%02d:%02d", hour, minute, secend];
}
}
#pragma mark - lazy
- (UIButton *)dismissBtn {
if (!_dismissBtn) {
......@@ -403,7 +388,7 @@
} cancel:^{
[weakSelf.timer setFireDate:[NSDate distantFuture]];
[weakSelf.timeCloseBtn setTitle:@"" forState:UIControlStateNormal];
}];
} defalutIndex:self.minuteIndex];
}
return _timingView;
}
......@@ -421,9 +406,7 @@
return;
}
weakSelf.countTime--;
NSString *countDownStr = [weakSelf formattimewithtimeinterval:weakSelf.countTime];
NSString *totalTimeStr = [weakSelf formattimewithtimeinterval:weakSelf.totalTime];
[weakSelf.timeCloseBtn setTitle:[NSString stringWithFormat:@"%@/%@",countDownStr, totalTimeStr] forState:UIControlStateNormal];
[weakSelf.timeCloseBtn setTitle:[NSString stringWithFormat:@"%@/%@", [NSString getFormatTime:weakSelf.countTime], [NSString getFormatTime:weakSelf.totalTime]] forState:UIControlStateNormal];
}];
[[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
}
......
......@@ -19,7 +19,7 @@ typedef void(^CancelBlock)(void);
/// 取消block
@property (nonatomic, copy) CancelBlock cancelBlock;
- (instancetype)initWithSureBlock:(TimingBlock)timingBlock cancel:(CancelBlock)cancelBlock;
- (instancetype)initWithSureBlock:(TimingBlock)timingBlock cancel:(CancelBlock)cancelBlock defalutIndex:(NSInteger)defalutIndex;
/// 显示定时器
- (void)display;
......
......@@ -24,12 +24,13 @@
@implementation TimingView
- (instancetype)initWithSureBlock:(TimingBlock)timingBlock cancel:(CancelBlock)cancelBlock {
- (instancetype)initWithSureBlock:(TimingBlock)timingBlock cancel:(CancelBlock)cancelBlock defalutIndex:(NSInteger)defalutIndex {
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
_currentTimeIndex = 0;
_currentTimeIndex = defalutIndex;
_sureIndex = defalutIndex;
_timingBlock = timingBlock;
_cancelBlock = cancelBlock;
self.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0x6F7587), DSClearColor, DSWhite);
self.backgroundColor = [self.backgroundColor colorWithAlphaComponent:0.6];
......
......@@ -50,7 +50,7 @@
[self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.equalTo(self);
make.right.equalTo(self.playBtn.mas_left).offset(-12);
make.width.equalTo(@100);
make.width.equalTo(@120);
}];
[self.playBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self);
......@@ -65,8 +65,8 @@
[self addGestureRecognizer:tap];
}
self.minuteIndex = 0;
self.countTime = 60;
self.minuteIndex = 9;
self.countTime = 60 * (self.minuteIndex + 1);
// 添加对单例对象白噪音播放列表变化通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noisePlaylistHasChange:) name:NoisePlaylistHasChange object:nil];
......@@ -179,7 +179,7 @@
} cancel:^{
[weakSelf.timer setFireDate:[NSDate distantFuture]];
weakSelf.timeLab.text = @"";
}];
} defalutIndex:self.minuteIndex];
}
return _timingView;
}
......@@ -196,28 +196,11 @@
return;
}
weakSelf.countTime--;
NSString *countDownStr = [weakSelf formattimewithtimeinterval:weakSelf.countTime];
NSString *totalTimeStr = [weakSelf formattimewithtimeinterval:weakSelf.totalTime];
weakSelf.timeLab.text = [NSString stringWithFormat:@"%@/%@",countDownStr, totalTimeStr];
weakSelf.timeLab.text = [NSString stringWithFormat:@"%@/%@", [NSString getFormatTime:weakSelf.countTime], [NSString getFormatTime:weakSelf.totalTime]];
}];
[[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
}
return _timer;
}
#pragma mark - others
- (NSString *)formattimewithtimeinterval:(NSTimeInterval)timeinterval {
int minute = 0, hour = 0, secend = timeinterval;
minute = (secend % 3600)/60;
hour = secend / 3600;
secend = secend % 60;
if (hour == 0) {
return [NSString stringWithFormat:@"%02d:%02d", minute, secend];
} else if (minute == 0){
return [NSString stringWithFormat:@"%02d", secend];
} else {
return [NSString stringWithFormat:@"%02d:%02d:%02d", hour, minute, secend];
}
}
@end
......@@ -183,7 +183,7 @@
if (!_oneClickBtn) {
_oneClickBtn = [UIButton btnWithTitle:@"" titleColor:DSWhite font:BoldFont(16) bgColor:BrandColor];
[_oneClickBtn addTarget:self action:@selector(oneClickAction:) forControlEvents:UIControlEventTouchUpInside];
[_oneClickBtn cornerRadius:22];
[_oneClickBtn cornerRadius:20];
[_oneClickBtn setTitle:@"一键开启" forState:UIControlStateNormal];
[_oneClickBtn setTitle:@"一键暂停" forState:UIControlStateSelected];
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!