It looks like you are trying to reinvent the wheel, unless I misunderstand your issues. I think you need to assess where your data/text is coming from (the source of the text), and then look at the similarities and differences with the:
UILabel class
UITextView class
UIWebView class
To answer the vertical alignment issue: As a hack, consider aligning the text vertically may be easier to do if you align the .center of your UILabel to the center of the region you want it centered to...
To answer the text formatting issues and font size:
Most of the items you are looking to do are built into the UILabel class [
link].
Specifically, have a look at:
textAlignment property
lineBreakMode property
adjustsFontSizeToFitWidth property
also, I recently came across:
sizeToFit, which is from UIView's class, which UILabel inherits from. I have had variable results with sizeToFit and other UILabel property combinations noted above. Here is the usage:
Code:
[myLabel sizeToFit]; // give this a try and see what happens
The hyphenation is something that you will need to manage separately, as finding where to break up a word and when to hyphenate it is a complex task that is language dependent, and may be too big of a task. Now if you already have hyphens in your text string, then you should be able to utilize the built in properties of UILabel.
If that fails, have a look at UITextView [
link]. UITextView has more text formatting options than UILabel, mainly the ability to edit with the keyboard and display. BUT just remember to disable scrolling and the keyboard interactivity as needed.
Alas, as a third option, have a look at UIWebView [
link], it can do a lot of formatting on the fly, and is good if your source is HTML or RTF (ie some file), and is not just for internet content, per se.