如何在MonoTouch中使用CoreText编写旋转文本?
我需要写一些旋转 90 度的文本。我首先尝试使用 CGAffineTransform 旋转 UILabel:
this.myLabel.Center = this.myLabel.Frame.Location;
this.myLabel.Transform = CGAffineTransform.MakeRotation (-(float)Math.PI / 2.0f);
它旋转得恰到好处,但字体现在看起来很模糊且难以阅读。
有没有办法使用 CoreText 库在 UILabel 中进行简单的文本旋转,并且看起来不模糊?
先感谢您!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您错过了,Xamarin 在 github 上提供了一个 示例,它使用 CoreText 来绘制(非旋转)文本。
由于文本最终作为路径,因此旋转整个文本应该不难。 OTOH CoreText 比旧的 API 复杂得多 - 这是获得(方式)更多控制权所付出的代价。
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.
您可以使用核心显卡。这有点复杂,但可以解决问题。
一个样本是:
You could use Core Graphics. It's a little involved, but will do the trick.
A sample would be: