【发布时间】:2017-10-22 13:17:03
【问题描述】:
我想在我的 NSTextView 中检查选定文本的范围是否以红色显示。我知道它符合 NSText 类,并且 NSText 中有一个 textColor 属性,但我无法获得我的 NSRange 选择的颜色。
有什么想法吗?
【问题讨论】:
-
这里是Set the background color of selected text in NSTextView的方法。获取前景色是类似的。获取
textStorage并枚举属性。 -
我如何枚举属性?
-
使用
NSAttributedStrings 枚举方法。
标签: swift text colors selection nstextview