public override void Draw (RectangleF rect) { Console.WriteLine ("# Draw: rect={{X={0}, Y={1}, Width={2}, Height={3}}}", rect.X, rect.Y, rect.Width, rect.Height); // Initialize a graphics context and set the text matrix to a known value var context = UIGraphics.GetCurrentContext (); // context.TextMatrix = CGAffineTransform.MakeIdentity (); context.TextMatrix = CGAffineTransform.MakeScale (1f, -1f); // initialize a rectangular path var path = new CGPath (); // path.AddRect (new RectangleF (10.0f, 10.0f, 200.0f, 30.0f)); path.AddRect (rect); RectangleF r; Console.WriteLine ("path.IsRect={0}; Width={1}, Height={2}", path.IsRect (out r), r.Width, r.Height); // initialize an attributed string var attrString = new NSMutableAttributedString ("We hold this truth to be self evident, that everyone is created equal."); // use a red font for the first 50 chars attrString.AddAttributes(new CTStringAttributes () { ForegroundColor = new CGColor ( CGColorSpace.CreateDeviceRGB(), new[]{1.0f, 0.0f, 0.0f, 0.8f} ), }, new NSRange (0, 50)); // Create the framesetter with the attributed string using (var framesetter = new CTFramesetter (attrString)) { NSRange fitRange; var size = framesetter.SuggestFrameSize (new NSRange (), null, new SizeF (200f, 200f), out fitRange); Console.WriteLine ("fitRange.Location={0}; fitRange.Length={1}", fitRange.Location, fitRange.Length); Console.WriteLine ("Size: Width={0}; Height={1}", size.Width, size.Height); // Create the frame and draw it into the graphics context using (var frame = framesetter.GetFrame (new NSRange (0, 70), path, null)) frame.Draw (context); context.ShowText ("hello, world!"); } }