2012-02-22 58 views
2

我正在使用MonoTouch.Dialog並創建自定義Section HeaderView。文本呈現顛倒。我錯過了什麼?MonoTouch.Dialog:顛倒標題視圖中的文本

screenshot

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(); 
    } 
} 

回答

2

UIKit的(IOS)和CoreGraphics中(iOS和OSX)具有不同的座標系。有關詳細信息(和圖形),請參見此link

UPDATE

這應該修復它:

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