Search code examples
iosxamarin.iosrotationuilabelcore-text

How to use CoreText in MonoTouch to write rotated text?


I need to write some text rotated by 90 degrees. I first tried with a UILabel rotated with CGAffineTransform:

this.myLabel.Center = this.myLabel.Frame.Location;
this.myLabel.Transform = CGAffineTransform.MakeRotation (-(float)Math.PI / 2.0f);

It rotated it just right, but fonts now look all blurred and difficult to read.

Is there a way to use the CoreText library to make a simple text rotation in a UILabel that doesn't look blurred?

Thank you in advance!


Solution

  • In case you missed it Xamarin provides a sample on github that use CoreText to draw (non-rotated) text.

    Since the text ends up as a path it should not be hard to rotate the whole text. OTOH CoreText is more much complicated than the older API - that's the price to pay to get (way) more control.