当前位置: 首页>>代码示例>>C#>>正文


C# CGContext.SetTextDrawingMode方法代码示例

本文整理汇总了C#中CGContext.SetTextDrawingMode方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.SetTextDrawingMode方法的具体用法?C# CGContext.SetTextDrawingMode怎么用?C# CGContext.SetTextDrawingMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGContext的用法示例。


在下文中一共展示了CGContext.SetTextDrawingMode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowCenteredTextAtPoint

		protected void ShowCenteredTextAtPoint (CGContext context, float centerX, float y, string text, int textHeight)
		{
			context.SelectFont ("Helvetica-Bold", textHeight, CGTextEncoding.MacRoman);
			context.SetTextDrawingMode (CGTextDrawingMode.Invisible);
			context.ShowTextAtPoint (centerX, y, text, text.Length);
			context.SetTextDrawingMode (CGTextDrawingMode.Fill);
			context.ShowTextAtPoint (centerX - (context.TextPosition.X - centerX) / 2, y, text, text.Length);
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:8,代码来源:View.cs

示例2: MeasureStringWidth

        // TODO: Cannot use NSAttributedString in iOS5, only iOS6+
//        public static RectangleF MeasureString(SizeF sizeConstraint, string text, string fontName, float fontSize)
//        {
//            NSMutableDictionary dict = new NSMutableDictionary();
//            dict.Add(NSAttributedString.FontAttributeName, NSFont.FromFontName(fontName, fontSize));
//            NSString nsstr = new NSString(text);
//            RectangleF rect = nsstr.BoundingRectWithSize(sizeConstraint, NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin, dict);
//            return rect;
//        }
        
        public static float MeasureStringWidth(CGContext context, string text, string fontName, float fontSize)
        {
			if (string.IsNullOrEmpty(text))
				return 0;

            context.SaveState();
            PointF pos = context.TextPosition;
            context.SelectFont(fontName, fontSize, CGTextEncoding.MacRoman);
            context.TextMatrix = CGAffineTransform.MakeScale(1.0f, -1.0f);
            //context.TranslateCTM(0, 20);
            context.ScaleCTM(1, -1);
            context.SetTextDrawingMode(CGTextDrawingMode.Invisible);
            context.ShowTextAtPoint(pos.X, pos.Y, text);
            PointF pos2 = context.TextPosition;
            context.RestoreState();
            
            return pos2.X - pos.X;
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:28,代码来源:CoreGraphicsHelper.cs

示例3: DrawTextAtPoint

		// Draws the specified text starting at x,y of the specified height to the context.
		protected void DrawTextAtPoint (CGContext context, float x, float y, string text, int textHeight)
		{
			// configure font
			context.SelectFont ("Helvetica-Bold", textHeight, CGTextEncoding.MacRoman);
			// set it to fill in our text, don't just outline
			context.SetTextDrawingMode (CGTextDrawingMode.Fill);
			// call showTextAtPoint
			context.ShowTextAtPoint (x, y, text, text.Length);
		}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:10,代码来源:Controller.cs

示例4: ShowTextAtPoint

		protected void ShowTextAtPoint (CGContext context, float x, float y, string text, int textHeight)
		{
			context.SelectFont ("Helvetica-Bold", textHeight, CGTextEncoding.MacRoman);
			context.SetTextDrawingMode (CGTextDrawingMode.Fill);
			context.ShowTextAtPoint (x, y, text, text.Length);
		}
开发者ID:rojepp,项目名称:monotouch-samples,代码行数:6,代码来源:Controller.cs

示例5: StartDraw

        public void StartDraw()
        {
            // Context properties
            this.mContext = UIGraphics.GetCurrentContext ();

            // -- Text
            mContext.SetTextDrawingMode (CGTextDrawingMode.Fill);
            mContext.TextMatrix = CGAffineTransform.MakeScale (1f, -1f);
        }
开发者ID:valryon,项目名称:pixpuzzle,代码行数:9,代码来源:PathGridView.cs

示例6: MeasureText

        public void MeasureText(CGContext c, Font f)
        {
            //			Console.WriteLine ("MEASURE {0}", f);

            c.SetTextDrawingMode (CGTextDrawingMode.Invisible);
            c.TextPosition = new PointF(0, 0);
            c.ShowText ("MM");

            var mmWidth = c.TextPosition.X;

            _height = (int)(f.Size * (11.0f / 16.0f));

            Widths = new float[0x80];

            for (var i = ' '; i < 127; i++) {

                var s = "M" + ((char)i).ToString() + "M";

                c.TextPosition = NativePoint.Empty;
                c.ShowText (s);

                var sz = c.TextPosition.X - mmWidth;

                if (sz < 0.1f) {
                    Widths = null;
                    return;
                }

                Widths[i] = (float)sz;
            }

            c.SetTextDrawingMode (CGTextDrawingMode.Fill);
        }
开发者ID:nissan,项目名称:CrossGraphics,代码行数:33,代码来源:CoreGraphicsGraphics.cs


注:本文中的CGContext.SetTextDrawingMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。