1

我正在使用 CATextLayer 来呈现 NSAttributedString。在此方法中完成时,颜色无法正确渲染。使用 CTStringAttributes 完成后,颜色会起作用,但 NSAttributedString 不知道自己的大小。这是我正在使用的代码:

    var caTextLayer = new CATextLayer (); 
    var attributedString = new NSAttributedString
    ( 
            "test string",
            ForegroundColor = UIColor.Blue.CGColor,
            Font = new CTFont ("Arial", 24),
            KerningAdjustment = 72f
    );


    caTextLayer.AttributedString = attributedString;
    caTextLayer.Frame = UIScreen.MainScreen.Bounds;
    caTextLayer.ContentsScale = UIScreen.MainScreen.Scale;

    myViewController.View.Layer.InsertSublayer(layer3, 1);

    caTextLayer.SetNeedsDisplay ();
4

1 回答 1

0

如果您使用 CoreText 图层,则需要使用 CTStringAttributes

于 2013-07-28T15:50:36.067 回答