【问题标题】:MonoTouch.Dialog: Upside down text in Section Header ViewMonoTouch.Dialog:部分标题视图中的颠倒文本
【发布时间】:2012-02-22 19:33:30
【问题描述】:

我正在使用 MonoTouch.Dialog 并创建自定义 Section HeaderView。文本呈现颠倒。我错过了什么?

public class SectionHeader: UIView
{
    string title;

    public SectionHeader (string Title): base(new RectangleF(0,0,320,40))
    {
        title = Title;
    }

    public override void Draw (RectangleF rect)
    {

        var topleft = new PointF (0, 0);
        var bottomright = new PointF (this.Frame.Width, this.Frame.Height);

        var context = UIGraphics.GetCurrentContext ();
        using (var cs = CGColorSpace.CreateDeviceRGB ())
        {
            using (var gradient = new CGGradient (cs, new float [] { 61f/255f, 1f/255f, 22f/255f, 1.0f, 1.0f, 1.0f,1.0f,1.0f }, new float [] { 0, 1 }))
            {
                context.DrawLinearGradient (gradient, topleft, bottomright, 0);
            }
        }

        context.SetFillColor (1, 1, 1, 1);
        context.SetTextDrawingMode (CGTextDrawingMode.Fill);
        context.TranslateCTM (0, 0);        
        context.SelectFont ("Helvetica", 20f, CGTextEncoding.MacRoman);
        context.ShowTextAtPoint (20, 20, title);
        context.StrokePath();   
    }
}

【问题讨论】:

    标签: c# uikit xamarin.ios core-graphics monotouch.dialog


    【解决方案1】:

    UIKit (iOS) 和 CoreGraphics(iOS 和 OSX)具有不同的坐标系。有关详细信息(和图形),请参阅此link

    更新

    这应该可以解决它:

    context.ScaleCTM (1.0f, -1.0f);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-21
      • 1970-01-01
      • 1970-01-01
      • 2013-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多