美文网首页
Playground Book

Playground Book

作者: a2ebcc3676c1 | 来源:发表于2018-03-07 18:58 被阅读184次

参考
官方文档
第三方案例

一、Annotations 注释

1. 单行标记
//:
2. 块标记
/*:
    line of text with optional markup
    ...
*/
3. 本地化标记
//:#localized(key: "FirstProseBlock")
  • 需要PrivateResources文件夹中的每个本地化文件夹中都有一个Prose.strings文件。
  • Prose.strings文件中内容格式
/* First block of prose for the page */
"FirstProseBlock"="Caring for a llama can be a challenging, but rewarding, experience.";
4. 单行可编辑区域
/*#-editable-code placeholder text*/content/*#-end-editable-code*/
  • content为空时,显示占位符内容
  • content区域用户可以编辑
  • 如果只允许用户编辑字符串,格式如下
/*#-editable-code*/"content"/*#-end-editable-code*/
5. 多行可编辑区域
//#-editable-code placeholder text
content
…
//#-end-editable-code
  • 该注释的格式要遵守代码书写格式,与上下文缩进格式相同,如:
for i in 1 ... 10 {
    //#-editable-code Tap to write your code
    //#-end-editable-code
}
6. 锁定可编辑区域
//#-editable-code
x += 4
//#-end-editable-code
7. 占位符可选类型
<#placeholder name#>
<#T##placeholder name##type#>
  • 可以使用swift中的数据类型,如
var typedLlamaCount = /*#-editable-code*/<#T##number of llamas##Int#>/*#-end-editable-code*/

var typedLlamaCount = /*#-editable-code*/<#T##number of llamas##Date#>/*#-end-editable-code*/

8. 隐藏代码
//#-hidden-code
line of code 
...
//#-end-hidden-code
  • 隐藏代码中的内容用户可用,只是看不见
9. 底部快捷栏
//#-code-completion(everything, hide)
//#-code-completion(identifier, show, moveForward(), turnLeft(), collectGem(), toggleSwitch())
//#-code-completion(identifier, hide, turnLeft())
//#-code-completion(identifier, show, turnRight())
//#-code-completion(keyword, for)

相关文章

网友评论

      本文标题:Playground Book

      本文链接:https://www.haomeiwen.com/subject/ukksfftx.html