1

NSAttributedString をレンダリングするために CATextLayer を使用しています。この方法で行うと、色が正しくレンダリングされません。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