我想在WatchKit中制作一个带有动画的按钮,但是似乎找不到一种方法来WKInterfaceButton
将图像修改或拖到情节提要中的按钮中。任何帮助表示赞赏。
经过研究,我找到了解决方案,它很简单,但很容易被忽略:)
首先,将按钮拖到故事板中创建的场景中。
其次,选择按钮,将其属性content
从修改Text
为Group
。如果找不到content
属性,请单击Attributes Inspector
屏幕右上方的按钮,它看起来像是断点按钮或带条的向下箭头。
现在,您可以控制在按钮内创建的组。您需要WKInterfaceGroup
在控制器代码中添加对此的引用。这是一个例子:
@interface AAPLButtonDetailController()
@property (weak, nonatomic) IBOutlet WKInterfaceGroup *buttonGroup;
@end
@implementation AAPLButtonDetailController
- (instancetype)init {
self = [super init];
if (self) {
// Initialize variables here.
// Configure interface objects here.
[_buttonGroup setBackgroundImageNamed:@"Bus"];
[_buttonGroup startAnimating];
}
return self;
}
因此,将在场景初始化后播放按钮动画。请记住,目前仅支持帧动画,一个动画中的所有帧都应命名为“ Bus0.png”,“ Bus1.png”...。
希望这可以帮助:)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句