2011-03-24 24 views

答えて

25

NSBackgroundColorAttributeNameが必要だと思います。以下のような:

迅速3.xの attributedString.addAttribute(NSBackgroundColorAttributeName, value: yourColor, range: NSMakeRange(0, tillLocation))

参考になったリンクについては

[mutableAttributedString addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:selectedRange]; 
+0

私のために働く。 iOSは私が使用した唯一のものです。 – DenVog

+0

bgの色を新しい行に入れずに、テキスト、単語、スペースだけを背景色にしたいのですが?ありがとう – KarenAnne

0

実際には黒い背景のビューに文字列を描画するのが最適な計画です。

+0

私は私がNSAttributedStringViewの色ではなく、文字列:)愚かな私を変更したいことが分かりました。 ..ありがとう! – asheinfeld