NSMutableAttributedString
メソッドを使用してそのプロパティを作成および設定しようとしていますSetProperties
。しかし、私のアプリはエラーでクラッシュし、
MonoTouch.Foundation.MonoTouchException exception - NSInvalidArgumentException Reason: unrecognized selector sent to instance 0xc305d00.*
コード:
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;
このコードは のGetCell
メソッドにありUITableViewController
ます。文字列の最初の 3 ~ 4 文字のみのフォントまたは色を変更できるようにしたい。
Fontコンポーネントを削除して、 StrokeWidthなどの別のプロパティを設定すると、正常に動作することがわかりました
var attrs = new CTStringAttributes { /*Font = font*/ StrokeWidth = 5f };
そのため、フォントの初期化が多少間違っているようです。何故ですか?アプリがクラッシュするのはなぜですか?
前もってありがとう!