Issue
I'm trying to colorize a substring in my NSMutableAttributedString in Xamarin, but it seems to be missing the proper constants,
What should I put there?
Update. This gets closer:
var s = new NSMutableAttributedString ("hello");
s.AddAttribute (CTStringAttributeKey.ForegroundColor , NSColor.Red, new NSRange (0, 3));
wordLabel.AttributedStringValue = s;
and gives
though the color on screen is still black text!
Update2 Maybe CTStringAttributeKey is the wrong one, but there is no NSStringAttributeKey
Solution
Ok, so I looked at the API and it seems it's there, just under NSAttributedString
So use something like:
s.AddAttribute(NSAttributedString.ForegroundColorAttributeName, NSColor.Red, new NSRange(0,3));
Answered By - ryrich
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.