2013-02-04 23 views
1

我使用下面的代碼片段繪製文字:的iPad - CGContextShowTextAtPoint用於多串

CGFloat DegreesToRadiansText(CGFloat degrees) {return degrees * M_PI/180;}; 
CGContextSelectFont (context, "Arial Rounded MT Bold", 18, kCGEncodingMacRoman); 
CGContextSetCharacterSpacing (context, 0); 
CGContextSetTextDrawingMode (context, kCGTextFill); 
CGContextSetGrayFillColor(context, 0.0, 1.0); 
CGAffineTransform myTextTransform = CGAffineTransformRotate(CGAffineTransformScale(CGAffineTransformIdentity, 1.f, -1.f),(DegreesToRadiansText (-90)); 
CGContextSetTextMatrix (context, myTextTransform); 
CGContextShowTextAtPoint (context, 552, 445, "iPhone\nUser", 11); 

上面的代碼工作正常,如果我畫單行文本。

但是,如果我添加多行文本(即文本具有'\ n'字符,如上面的代碼所示),它顯示爲單行文本。

現在我得到的輸出,如圖所示:

http://tinyurl.com/crrz9ew

,但我想輸出像如圖所示:

http://tinyurl.com/ctntbfk

有沒有辦法與我可以使用函數CGContextShowTextAtPoint來繪製多行字符串還是有其他的選擇嗎?

在此先感謝。

回答

0

您可以將其繪製爲CGContext的drawInRect:withAttributes方法 您必須提供繪製文本的高度。