如何在普通文本视图中使用Swift Playgrounds风格的代码输入键盘/文本字段?

时间:2023-01-23 18:02:22

I'm making an iPad app that lets me write swift code into a text box and save it to a document. It doesn't do any compilation or any complicated stuff like that, so I'm just looking for a way to format the code correctly in the text box (ex: code autocomplete, autoindent if possible, and maybe syntax highlighting). In short, I'd like my app's text field and keyboard to look similar to those of Swift Playgrounds.

我正在制作一个iPad应用程序,它允许我将快速代码写入文本框并将其保存到文档中。它没有做任何编译或任何复杂的东西,所以我只是想找到一种方法在文本框中正确格式化代码(例如:代码自动完成,如果可能的话,自动注册,也可能是语法高亮)。简而言之,我希望我的应用程序的文本字段和键盘看起来与Swift Playgrounds类似。

If Apple's provided the code (or a built-in keyboard option that can do even some of this), I'd appreciate a link to it. Otherwise, how would I go about building a custom keyboard and text field (or at least disable the features like autocomplete that would get in the way)?

如果Apple提供了代码(或内置的键盘选项,甚至可以做其中一些),我会很感激它的链接。否则,我将如何构建自定义键盘和文本字段(或至少禁用自动完成功能会阻碍)?

Thanks.

1 个解决方案

#1


0  

As far as I know the only way to do what you describe is to build a Swift Playgrounds app that presents a code editor window. Apple does provide documentation on creating third party iPad Swift playgrounds. I suggest looking it up on Apple's site.

据我所知,你所描述的唯一方法就是构建一个提供代码编辑器窗口的Swift Playgrounds应用程序。 Apple确实提供了有关创建第三方iPad Swift游乐场的文档。我建议在Apple的网站上查找。

#1


0  

As far as I know the only way to do what you describe is to build a Swift Playgrounds app that presents a code editor window. Apple does provide documentation on creating third party iPad Swift playgrounds. I suggest looking it up on Apple's site.

据我所知,你所描述的唯一方法就是构建一个提供代码编辑器窗口的Swift Playgrounds应用程序。 Apple确实提供了有关创建第三方iPad Swift游乐场的文档。我建议在Apple的网站上查找。