I have an Android app with a UI like this for viewing emails:

I’m trying to port this to iOS and need it to work with iOS 5.0 and above (so can’t use auto-layout in iOS 6.0). Hopefully you can tell how the layout should adjust/flow based on the example.
What would be the best way to handle this type of layout? The From and Re lines need to be variable height as shown (actually the To: line as well). The message body needs to be variable height of course.
My only attempt so far has been trying to use UITableViewController with static cells. I am able to get the variable height that way, by using sizeWithFont inside heightForRowAtIndexPath, to return the required height for each row. Using that method I’m having a heck of a time trying to get the style I want (rounded corners and background only for the top part).
So is there a better way? Maybe something that uses Collection View or Container View? On some other screens I need to port I have similar issues, but they have more levels of nesting (rounded blue section inside a white section inside a rounded blue section). Or would I be better off not using IB and building the entire UI in code from just basic label elements and generic views?
The easiest way I can think of is to manually compute for the label frames inside
viewDidLayoutSubviews. Here’s some pseudo-code:On creation:
viewDidLoad, set the containing view’s layer cornerRadius, borderColor, etc. as appropriate.In
viewDidLayoutSubviews:sizeWithFont:To:,From:, andRe:; callsizeToFit. Get the max width and hold on to that.To:label: Set the x to 0 and y to the time label’s bottom.sizeWithFont:.From:andRe:rows.You have to add paddings on your own because
sizeToFitandsizeWithFont:won’t do that for you. Also, the bodyUITextViewcan scroll on it’s own, but if you are expecting long subject titles then you should wrap the whole thing in anotherUIScrollView(or in IB just set the main view’s class toUIScrollView)