How do I autosize Labels so they contain all the text, but don't take up any more space then necessary and stay vertically spaced the same whether the user is in portrait or landscape mode?

I am trying to implement a simple control that displays information about my app in paragraph form. It will have Headings, and Paragraphs. I am having problems correctly positioning things relative to each other and have them auto adjust as the user rotates their device and changes orientation.

In the example below, I have 4 labels. 2 are for headings and are bolded with larger font, 2 have standard font, but are long and have lots of text. I want to be able to have all the text visible on each label and have none cut off. I also, want all the labels as close as they can be to each other. So, their containing rectangles have to change based on all of the other label's height. So when I change from landscape to portrait orientation, the paragraphs may take 8 lines instead of the 3 lines it takes in landscape mode. I want the controls to shift to have the same amount of Vertical white space between each of them.

Here is a sample:

About this program

Thank you for downloading this app. It is designed to do some wonderful things and will make all your wildest dreams come true.

Help

In order to use this program, use the tab bar at the bottom of the screen to select what you want to do. When the view opens, slide the items across the view until you are done.

有帮助吗?

解决方案 2

I followed the advice in Jason's comment and it works like a charm:

Try using a UIWebView and embedded HTML for your content. – Jason Oct 30 at 19:23

Thanks Jason !!

其他提示

I'll quote Mattt Thompson:

enter image description here

This is the type of thing TextKit was created for. Check out Wenderlich's tutorial for an easy start.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top