Is there a CoreText equivalent for the iPhone SDK?
Is there a CoreText equivalent for the iPhone SDK? I just need to draw a paragraph of text and programmatically align it to the center of the screen based on the height of 开发者_如何学Gothe paragraph. UITextfield is overkill for this I think.
Core Text is available from iOS 3.2 and is including in iOS 4.0. For details, look at the Core Text Programming Guide.
I"m not sure you need core text, you can use
CGSize cs = [theString sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:CGSizeMake(width,FLT_MAX) lineBreakMode:UILineBreakModeWordWrap];
to get the height of the paragraph. Aligning it with that info should be pretty easy.
精彩评论