これは特定のバグではなく、何かを行う方法がわからないことに関するものです。
私は NSTextView を持っており、ユーザーがテキスト ビューの特定の部分をクリックしたときに、特定の範囲のテキストの背景をペイントする必要があります。私はこれを試しましたが、テキストの前景色が失われたり、背景が範囲全体に及ばないことがあります。
NSLayoutManager *layoutManager = [myTextView layoutManager];
[layoutManager removeTemporaryAttribute:NSBackgroundColorAttributeName
forCharacterRange:range];
[[myTextView layoutManager] setTemporaryAttributes:attributes
forCharacterRange:range];
簡単にするために、 range は常に有効な文字列であると仮定します (これは私のテスト環境にあります)。