简体   繁体   English

如何实现WatchKit滑动按钮?

[英]How to implement WatchKit sliding button?

Is there a way to implement a sliding button on the watch, similar to the power button linked below? 有没有办法在手表上实现滑动按钮,类似于下面链接的电源按钮?

power off screen from watch 从手表关闭屏幕

You can create a custom button with the help of SpriteKit in WatchOS 3 or later. 你可以的帮助下创建一个自定义按钮SpriteKit在WatchOS 3或更高版本。 Add SKScene and give pan gesture or swipe gesture to it. 添加SKSceneSKScene添加平移手势或滑动手势。

I ended up using SpriteKit to add an SKSpriteNode to the scene with my image. 我最终使用SpriteKit将SKSpriteNode添加到我的图像场景中。 It doesn't have the smoothness of the power off slider, but that could probably be tweaked. 它没有断电滑块的平滑度,但可能会调整。 Using an SKAction to move the icon instead of setting the coordinates directly helped but it's not perfect. 使用SKAction移动图标而不是直接设置坐标,但它并不完美。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM