C# 设置CTStringAttributes字体后无法访问字符串大小

C# 设置CTStringAttributes字体后无法访问字符串大小,c#,ios,xamarin.ios,C#,Ios,Xamarin.ios,我正在尝试使用带有字距和特定字体的字符串渲染CATextLayer。如果使用CATextLayer设置字体,则字体无法正确呈现。如果在CTStringAttributes中设置字体,则会出现以下错误: Unhandled Exception: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[__NSCFType sc

我正在尝试使用带有字距和特定字体的字符串渲染CATextLayer。如果使用CATextLayer设置字体,则字体无法正确呈现。如果在CTStringAttributes中设置字体,则会出现以下错误:

Unhandled Exception:

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.
Name: NSInvalidArgumentException
Reason: -[__NSCFType screenFontWithRenderingMode:]: unrecognized selector sent to instance 0x13dba570
以下是我尝试使用的代码:

CTStringAttributes ctsa = new CTStringAttributes();

//This method returns what out kerning should be loosely based on the 
//tracking number our UI designer uses in Adobe Illustrator
var trackingSize = MyFonts.IllustratorTracking(200f * 0.8f,
                                               MyFonts.CardHeader.PointSize);
ctsa.KerningAdjustment = trackingSize;
ctsa.ForegroundColor = MyColors.CardHeaderText.CGColor;
ctsa.Font = MyFonts.CardHeaderCT;
NSAttributedString someString = new NSAttributedString(title, ctsa);

titleLayer = new CATextLayer();
titleLayer.Frame = new RectangleF(19, ((20 - someString.Size.Height) / 2.0f),
                                  someString.Size.Width,
                                  someString.Size.Height);
titleLayer.ForegroundColor = MyColors.CardHeaderText.CGColor;
titleLayer.BackgroundColor = UIColor.Clear.CGColor;
titleLayer.AttributedString = someString;
headerView.Layer.AddSublayer(titleLayer);