Inside the UIView subclass, I override the Draw sub to draw some custom text, but the text allways is drawn as flip text.
This is the code I am using:
class TextViewProblem : UIView
{
public override void Draw (RectangleF rect)
{
base.Draw (rect);
CGContext g = UIGraphics.GetCurrentContext();
UIColor.White.SetFill();
g.SelectFont("Arial",16f,CGTextEncoding.MacRoman);
UIColor.White.SetFill();
g.SetTextDrawingMode(CGTextDrawingMode.Fill);
g.ShowTextAtPoint(1,25,"Yiannis 123");
}
}
And this is the output of this code:
Why is the text drawn flipped?
I am running: MonoDevelop 2.4.2 iPhone Simulator 4.2 MonoTouch 3.2.6
You can download a project to reproduce this issue from this link: www.grbytes.com/downloads/TextProblem.zip
The image is flipped because the coordinate system for CoreGraphics is not the same as for UIKit, you need to apply a transformation that includes flipping around the rendering (scale by x=1, y=-1) and then translate by the height (x=0, y=height).
You do this by applying the transformation to your graphics context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With