Ejemplo n.º 1
0
        public void SimpleValuesSet()
        {
            var sa = new CTStringAttributes();

            sa.ForegroundColor         = UIColor.Blue.CGColor;
            sa.Font                    = new CTFont("Georgia-BoldItalic", 24);
            sa.UnderlineStyle          = CTUnderlineStyle.Double;    // It does not seem to do anything
            sa.UnderlineColor          = UIColor.Blue.CGColor;
            sa.UnderlineStyleModifiers = CTUnderlineStyleModifiers.PatternDashDotDot;

            Assert.IsNull(sa.BaselineClass, "#0");
            sa.BaselineClass = CTBaselineClass.IdeographicHigh;
            Assert.AreEqual(CTBaselineClass.IdeographicHigh, sa.BaselineClass, "#1");

            sa.SetBaselineInfo(CTBaselineClass.Roman, 13);
            sa.SetBaselineInfo(CTBaselineClass.IdeographicHigh, 3);
            sa.SetWritingDirection(CTWritingDirection.LeftToRight);

            var size = new SizeF(300, 300);

            UIGraphics.BeginImageContext(size);
            var gctx = UIGraphics.GetCurrentContext();

            gctx.SetFillColor(UIColor.Green.CGColor);

            var attributedString = new NSAttributedString("Test_ME~`", sa);

            using (var textLine = new CTLine(attributedString)) {
                textLine.Draw(gctx);
            }

            UIGraphics.EndImageContext();
        }