PDA

View Full Version : Drawing text in a custom view




JohnGaby
Nov 16, 2009, 10:34 AM
I am new to iPhone development (and to mac development in general). I am trying to figure out how to draw text in a custom view. I can use the function CGContextShowTextAtPoint to draw the text, but how do I get information about the text extent so I can center or right justify the string?

Thanks



dejo
Nov 16, 2009, 10:37 AM
Why not just use a UILabel?

JohnGaby
Nov 16, 2009, 11:00 AM
Thanks for the reply. I am aware of UILabel, but I would rather not have to create a label for each piece of text that I wish to display. I was hoping that there would be a mechanism where I could output the text directly to the device context.

AndyCodez
Nov 16, 2009, 12:37 PM
UITextView?

PhoneyDeveloper
Nov 16, 2009, 01:53 PM
UIStringDrawing.h

Stay away from CG text drawing if at all possible. It's very complex.