WKInterfaceImage的setImageData文档说:“数据可以是原始图像数据,也可以是存档的UIImage对象。……该参数中的数据对象可能包含多个图像,以便图像内容可以被动画化。”
有人能告诉我如何从多个图像构建一个NSData对象的代码片段,可以加载到WKInterfaceImage对象中吗?
这是我能解释的最好的方法。
UIImage * img1 = [UIImage imageNamed:@"img1.png"];
UIImage * img2 = [UIImage imageNamed:@"img2.png"];
UIImage * img = [UIImage animatedImageWithImages:@[img1, img2] duration:0];
NSData * data = [NSKeyedArchiver archivedDataWithRootObject:img];
[self.wkInterfaceImage setImageData:data];
[self.wkInterfaceImage startAnimating];但这不管用!
发布于 2015-04-15 16:14:42
不要使用setImageData,只使用setImage并直接传递图像。
self.wkInterfaceImage setImage:img];此外,您还需要将动画图像的持续时间更改为大于0的内容。
https://stackoverflow.com/questions/29655302
复制相似问题