如何在Apple WatchKit中制作循环进度动画?

时间:2022-06-22 23:01:19

I have 50 circular images (progress-1.png, progress-2.png, etc) that represent the progress of a circle. If I come up with a percentage value, how can I animate the background image of a group to show the progress of that percentage value?

我有50个圆形图像(progress-1.png,progress-2.png等),代表圆圈的进度。如果我想出百分比值,我该如何设置组的背景图像动画以显示该百分比值的进度?

1 个解决方案

#1


You can use something like this:

你可以使用这样的东西:

// Using a fixed percentage for this example
CGFloat percentage = 0.5f;
NSUInteger totalImages = 50;
NSUInteger imageCount = (totalImages * percentage);

[self.interfaceImage setImageNamed:@"progress-"];
[self.interfaceImage startAnimatingWithImagesInRange:NSMakeRange(0, imageCount)
                                            duration:1.0
                                         repeatCount:1];

#1


You can use something like this:

你可以使用这样的东西:

// Using a fixed percentage for this example
CGFloat percentage = 0.5f;
NSUInteger totalImages = 50;
NSUInteger imageCount = (totalImages * percentage);

[self.interfaceImage setImageNamed:@"progress-"];
[self.interfaceImage startAnimatingWithImagesInRange:NSMakeRange(0, imageCount)
                                            duration:1.0
                                         repeatCount:1];