swift - 如何在 Apple WatchKit 中设置循环进度动画?

标签 swift ios8 xcode6 watchkit apple-watch

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

最佳答案

你可以这样使用:

// 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];

关于swift - 如何在 Apple WatchKit 中设置循环进度动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30039160/

相关文章:

swift - 使用 NSSpeechStatusNumberOfCharactersLeft 更新 NSSpeechSynthesizer 的进度指示器

iOS 导航右栏按钮项目 - 图标在对话框后更改

ios - 使用 NSTimer 从服务器刷新数据

ios - 将 Swift String 转换为 UTF-8 并使用 char 的 ASCII 值进行算术运算

ios - 以编程方式向 UIView 添加约束

ios - 在 AppDelegate 中自定义 UISearchBar 和 UINavigationBar 的外观?为什么要在类而不是实例级别进行定制?

ios - Xcode 7 是否支持 iOS 8.0 模拟器?

ios - Xcode6:嵌入式二进制文件未使用与父应用程序相同的证书进行签名

xcode - Swift:2个连续的闭包/ block

ios - 管理 iOS 应用程序的多个版本