I'm trying to create NSMutableAttributedString
and set its properties with SetProperties
method. But my app crashes with error,
MonoTouch.Foundation.MonoTouchException exception - NSInvalidArgumentException Reason: unrecognized selector sent to instance 0xc305d00.*
Code:
var richTask = new NSMutableAttributedString ("Random");
var fda = new CTFontDescriptorAttributes {
FamilyName = "Courier",
StyleName = "Bold",
Size = 18f
};
var fd = new CTFontDescriptor (fda);
var font = new CTFont (fd, 0);
var attrs = new CTStringAttributes { Font = font };
var range = new NSRange (0, 3);
richTask.SetAttributes(attrs, range);
_label.AttributedText = richTask;
This code is in the GetCell
method of UITableViewController
. I want to be able to change font or color only of the first 3-4 letters of the string.
I figured out that if I eliminate Font component and set another property, for example, StrokeWidth, it works fine
var attrs = new CTStringAttributes { /*Font = font*/ StrokeWidth = 5f };
So it seems that font is initialized somewhat incorrect. Why is that? Why does it crash my app?
Thanks for advance!