Bug 19263 - Setting color of text via NSAttributeString not working
Summary: Setting color of text via NSAttributeString not working
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.2.0
Hardware: Other Other
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2014-04-24 01:16 UTC by dj_technohead
Modified: 2017-09-06 05:38 UTC (History)
6 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 19263 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description dj_technohead 2014-04-24 01:16:50 UTC
Setting the color attribute of a string isn't working:

string text = "This is a test message";
			var str = new NSMutableAttributedString (text);

			str.AddAttribute (CTStringAttributeKey.Font, UIFont.FromName("AmericanTypewriter-Bold", 20f), new NSRange (0, 5));
			str.AddAttribute (CTStringAttributeKey.ForegroundColor, UIColor.Red, new NSRange (0, 5));
			this.lblLabel.AttributedText = str;

The word "This" is being shown in a large American Typewriter font, but it is not being shown in red.
Comment 1 Sebastien Pouliot 2014-04-24 08:06:11 UTC
Please include all version of the software* you're using and also the version of iOS (simulator and devices) that were used to test this.

* The easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button).
Comment 2 dj_technohead 2014-04-24 12:38:05 UTC
This was only tested so far on the simulator (iOS 7.1)

Xamarin Studio
Version 4.2.3 (build 60)
Installation UUID: bfa92f08-b54c-43ca-baac-4c06dda9ee77
	Mono 3.2.6 ((no/9b58377)
	GTK+ 2.24.23 theme: Raleigh
	GTK# (
	Package version: 302060000

Apple Developer Tools
Xcode 5.1.1 (5085)
Build 5B1008

Version: (Business Edition)
Hash: 58c3efa
Build date: 2014-10-03 18:02:26-0400

Operating System
Mac OS X 10.9.2
Darwin denniss-air-3 13.1.0 Darwin Kernel Version 13.1.0
    Thu Jan 16 19:40:37 PST 2014
    root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64
Comment 3 dj_technohead 2014-04-26 01:08:47 UTC
Found a workaround:

	NSAttributedString nsaTest = new NSAttributedString("this ", new UIStringAttributes() {
					ForegroundColor = UIColor.Red,

	NSMutableAttributedString nsmas = new NSMutableAttributedString(nsaTest);
	nsmas.Append(new NSAttributedString(" is a test "));

However, the original bug still stands.
Comment 4 Sadik Ali 2014-10-30 03:54:39 UTC
We have checked this issue and able to reproduce with the help of bug description.

We observed that set color of text via NSMutableAttributedString is not working.We set text color to right but in output screen there is default color set.

Screencast regarding Same:


Environment Info:
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

Xamarin (e78d10d6993f95fc3ebe791aeb4aacff165bf8bb)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (0ef616ae42005ece52f6df7aa1e093ceb11998f8)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS (209abebbd8f1a292d042420edb45fa5fbd3f017b)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 5 Nishant Gaurav 2017-09-06 05:38:24 UTC Comment hidden (spam)