views:

222

answers:

1

I want to draw a text with different colors and the only way that I've found for do it is to split every piece of string-color in differents UILabels, so currently now I have four UILabels one after another, lets say, label1, label2, label3 and label4.

The problem with that is with the size and the position of every labels, I've not found an automatic way for do it.

The only way is:

  1. Set the text inside all the labels
  2. Ask for the width of all the labels with this new text
  3. Resize all the labels with this new width
  4. Move label2 to label1.x + label1.width, and so on

This is really the only way in iPhone for do that?

I came from Android and there is a "wrap_content" property for every view and "relative_layouts" where you can define something like.. put label2 rightOf label1. So I'm looking of something simple and automatic like that, but in iPhone.

Thanks!

+1  A: 

Depending on your application, you might want to consider a single UIWebView instead. Then you can style the content of it with HTML and CSS.

chrisbtoo
My idea was to use the native environment, not the web view. So I think that there is no way to do that. Thanks anyways.
zegnus