使用 monotouch,我尝试在多行上显示核心文本元素。我尝试使用的示例来自CoreText_Programming p17。我遇到的一个问题是无法找到 CFMutableAttributedStringRef 的等效项,因此我尝试将其替换为 NSAttributedString,但是以下代码没有显示任何内容。有谁知道单触式中这种类型的任何例子,或者知道以下不起作用的原因。谢谢。
public override void Draw (RectangleF rect)
{
base.Draw (rect);
CGContext context = UIGraphics.GetCurrentContext ();
context.TextMatrix = new CGAffineTransform();
CGPath path = new CGPath();
path.AddRect ( this.Bounds );
// created dictionary so this line does not crash
NSAttributedString stringToDraw = new NSAttributedString( "Hello", new NSDictionary() );
CTFramesetter framesetter = new CTFramesetter(stringToDraw);
CTFrame frame = framesetter.GetFrame( new NSRange(0,0), path, null );
frame.Draw( context );
}