本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
示例5: StartDraw
public void StartDraw()
{
// Context properties
this.mContext = UIGraphics.GetCurrentContext ();
// -- Text
mContext.SetTextDrawingMode (CGTextDrawingMode.Fill);
mContext.TextMatrix = CGAffineTransform.MakeScale (1f, -1f);
}
示例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);
}