Has anyone got a good copyfitting routine for iOS? I basically want to draw the largest text that will fit inside a rectangle. The previous way I did it in Carbon was to create the text at a huge font size, then keep reducing the size until the text fit completely in the box. In Carbon, there was a way I could tell that the text overflowed the rect. I've looked through the CoreText definition, and the UITextView definitions, and haven't found where this information is. I'm about to look through Quartz, but I fear that I probably have to write my own layout routines. I'm hoping someone can save me some time.
There's a way to do the opposite of the method you mentioned you'd done before--instead of determining the largest text that can fit in a rect, you can determine the size of the rect that is needed to contain text at a certain font size:
[@"Your Text Here" sizeWithFont:[UIFont fontWithName:@"Arial" size:34]];
Seems like you could do the same algorithm you mentioned but in reverse, increasing the font size until it was the largest size that could fit in your rect without overflowing it.
It's entirely possible there's a better way to do this, but I don't see why this method wouldn't work :)