Ios 倒计时计时器的圆形进度条/饼图
我有一个15秒的定时器在我的应用程序中的循环进度条排序动画将包含在秒的中心标签的要求 下面的代码给出了从0.0到1.0f的labelprogress,但是我想用平滑动画将它映射到15秒倒计时,如果有计时器延长器,那么它应该得到与平滑动画一起添加的时间 首先,我需要从15秒开始,如果用户单击timeextender通电,当前时间是10秒,那么它应该是25秒,相应地,progressbar百分比应该可以工作 那么我需要映射什么逻辑来完成上述需求呢Ios 倒计时计时器的圆形进度条/饼图,ios,objective-c,progress-bar,countdown,countdowntimer,Ios,Objective C,Progress Bar,Countdown,Countdowntimer,我有一个15秒的定时器在我的应用程序中的循环进度条排序动画将包含在秒的中心标签的要求 下面的代码给出了从0.0到1.0f的labelprogress,但是我想用平滑动画将它映射到15秒倒计时,如果有计时器延长器,那么它应该得到与平滑动画一起添加的时间 首先,我需要从15秒开始,如果用户单击timeextender通电,当前时间是10秒,那么它应该是25秒,相应地,progressbar百分比应该可以工作 那么我需要映射什么逻辑来完成上述需求呢 - (void)progressChange {
- (void)progressChange
{
// Labeled progress views
NSArray *labeledProgressViews = @[//self.labeledProgressView,
self.labeledLargeProgressView];
for (DALabeledCircularProgressView *labeledProgressView in labeledProgressViews) {
CGFloat progress = ![self.timer isValid] ? self.stepper.value / 10.0f : labeledProgressView.progress + 0.01f;
[labeledProgressView setProgress:progress animated:YES];
labeledProgressView.progressLabel.text = [NSString stringWithFormat:@"%.2f", labeledProgressView.progress];
}
}
- (void)startAnimation
{
self.timer = [NSTimer scheduledTimerWithTimeInterval:0.03
target:self
selector:@selector(progressChange)
userInfo:nil
repeats:YES];
self.continuousSwitch.on = YES;
}
- (void)stopAnimation
{
[self.timer invalidate];
self.timer = nil;
self.continuousSwitch.on = NO;
}
- (IBAction)TimeExtender:(id)sender
{
if (labeledProgressView.progress >= 1.0f && [self.timer isValid]) {
[labeledProgressView setProgress:0.f animated:YES];
}
}
我自己解决的这是密码
- (void)progressChange
{
CGFloat progress ;
DALabeledCircularProgressView *labeledProgressView = self.labeledLargeProgressView;
if(labeledProgressView.progress >=1.0f && [self.timer isValid]){
[self stopAnimation];
seconds = 15.0f;
}
else{
progress=labeledProgressView.progress + 0.06666667f;
[labeledProgressView setProgress:progress animated:YES];
seconds --;
labeledProgressView.progressLabel.text = [NSString stringWithFormat:@"%i", seconds];
}
}
- (void)startAnimation
{
self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(progressChange)
userInfo:nil
repeats:YES];
self.continuousSwitch.on = YES;
}
你还没有给出你的进度百分比的具体位置和内容animation@Shayanya好的,等等,我也会用这个代码更新上面的问题…好的,我自己解决了。。。。