问题描述
我正在尝试为我的应用的Apple Watch版本创建一个进度圈。我知道我们无法使用UIViews(这会让事情变得如此简单!)所以我正在寻找其他选择。
I am trying to create a progress circle for the Apple Watch version of my app. I know that we aren't able to use UIViews (which would make things so much easier!) so I am looking for alternatives.
基本上,我想创建其中一个原型:
Basically, I would like to create one of these prototypes:
我希望做的事情是将背景图层添加为普通的WKInterfaceImage,然后将顶部的进度箭头/线条添加为围绕圆圈旋转的WKInterfaceImage基于计算的百分比。
The way I was hoping to do things was to add the background layers as a normal WKInterfaceImage and then the progress arrow/line on top as a WKInterfaceImage that rotates around the circle based on the percentage calculated.
我的计算百分比基本上如此,我正在寻找的是旋转箭头的数学代码的一些帮助。
I have the percentage calculated so basically, what I am looking for is some help with the math code for rotating the arrow.
有人知道这是否可行,如果有的话,任何人都可以帮助我吗?我不是在应用程序运行时尝试更新圈子;它只需要在Watch App启动以与iOS版本对应时更新。
Does anyone know if this is possible, and could anyone help me out if so? I'm not trying to update the circle while the app is running; it just needs to update when the Watch App launches to correspond with the iOS version.
谢谢!
推荐答案
另一种解决方案是创建100张图片,每个数字都有一个框架。因此,这样做,您可以使用'startAnimatingWithImagesInRange:duration:repeatCount'方法显示动画。
Another solution is to create 100 picture, for each number you have a frame. So, doing that, you can show an animation using 'startAnimatingWithImagesInRange:duration:repeatCount' method.
问题是很难自定义每一帧。有人想到了这个问题并创造了一个发电机。你可以用这个名字找到它:
The problem is that it's hard to customise each frame. Somebody thought about this issue and created a generator. You can find it by this name:
此链接可帮助您自定义框架:
This link should help you to customise the frames: http://hmaidasani.github.io/RadialChartImageGenerator/
您在git链接上也有相同的示例。
对于具有单个弧框的100帧,您在磁盘上获得大约1,8 MB的空间。
Also you have same samples on git link.For 100 frames with a single arc frame you get around 1,8 MB on disk.
这篇关于在Watch App中将进度循环创建为WKInterfaceImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!