Rec*_*Hou 7 xcode objective-c ios watchkit
我想在WatchKit中创建一个带动画的按钮,但似乎我无法找到一种方法来修改WKInterfaceButton或将图像拖动到故事板中的按钮.任何帮助表示赞赏.
Rec*_*Hou 20
经过一些研究后我找到了解决方案,它非常简单但很容易被忽略:)
首先,将按钮拖动到故事板中创建的场景中.
其次,选择按钮,修改其属性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;
}
Run Code Online (Sandbox Code Playgroud)
因此,按钮动画将在场景初始化后播放.请记住,目前仅支持帧动画,一个动画中的所有帧都应命名为"Bus0.png","Bus1.png"....

希望这可以帮助:)
| 归档时间: |
|
| 查看次数: |
5162 次 |
| 最近记录: |