【发布时间】:2014-11-19 05:46:06
【问题描述】:
我想知道是否有一种方法可以使用 Swift 编程语言使每个单词中的字母都着色。我正在寻找想法和线索。
例子:
println("This is a string")
看起来像这样:
如果这有帮助,我发现其他语言能够通过 javascript 和 microsoft word 专门用颜色为每个字母着色。我没有线索,任何会有所帮助。谢谢!
示例: https://superuser.com/questions/230665/how-do-i-change-the-font-color-of-a-specific-letter-throughout-the-entire-ms-wor Is there any clean CSS method to make each letter in a word a different color?
【问题讨论】:
-
没问题,只需使用 NSAttributedString 并为每个字符赋予不同的颜色。
-
在这里查看我的答案stackoverflow.com/a/26726865/341994 并注意插图:有些字母有不同的颜色。你的只是一个极端的例子! :)
标签: xcode swift xcode6 swift-playground generics