How to add a label to AppleWatch programmatically?

你说的曾经没有我的故事 提交于 2019-12-31 04:00:27

问题


I'm new to AppleWatch development but I find I can't add a label (or button) to AppleWatch screen programmatically. All I can do is just adding the assets via storyboard.

Can I ask how to add label or button to the screen programmatically? And how to set their position to x and y on the screen? Objective C solution is preferred.

Thank you!


回答1:


You can't. View hierarchy in Apple Watch development is statically declared in storyboards at compile time. If you want a label to be conditionally visible, make it in the storyboard and set it to hidden. It is then possible to unhide the view programmatically at runtime.



来源:https://stackoverflow.com/questions/28691579/how-to-add-a-label-to-applewatch-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!