c# - MonoTouch.Dialog:节标题 View 中颠倒的文本

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

我正在使用 MonoTouch.Dialog 并创建自定义部分标题 View 。文本呈现颠倒。我错过了什么?

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

最佳答案

UIKit (iOS) 和 CoreGraphics(iOS 和 OSX)具有不同的坐标系。看这个link了解详细信息(和图形)。

更新

这应该解决它:

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

关于c# - MonoTouch.Dialog:节标题 View 中颠倒的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9401673/

相关文章:

ios - 如何隐藏 CALayer 的边框而不导致 iOS 中的渲染问题

ios - 将 PointF[] 转换为 CGPoint[]

xamarin.ios - 无法将 cookie 添加到 NSHttpCookieStorage.SharedStorage

c# - 保存静态信息的表的名称是什么

c# - StackPanel.Children.Clear() 无法正常工作

ios - 如何快速组织uitableview的动态数量作为滑动页面

ios - 没有 reuseIdentifier 的 UITableViewCell

c# - C#黑白图像处理

c# - 向字符串类 C# 添加新属性

ios - 如何创建 UIView 弹跳动画?