1

我正在尝试使用带有字距调整和特定字体的字符串来渲染 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);
4

0 回答 0