I have about 400 character length string with a heading called Details. In this 'Details' is to be bold and of fontsize 19. While all the remaining text starts in the next line and should be of fontSize 18 like the contents. How can I do all this by using a UILabel? Plz help me...
You can't do it with a stock UILabel
as of SDK 3.2. You can create an NSAttributedString
that specifies particular styles (like bold) for particular parts of the string, but there isn't a simple way to actually render it. This is unlike In Max OS X, which has NSAttributedString(AppKitAdditions)
, which allows you to draw an attributed string in a single line of code. If you want to render it, you can, but you'll have to delve into one of the lower level APIs (such as Core Text).
You're probably much better off using two UILabel
s. Make the first one bold, and make the second one cover multiple lines.
Since UILabel does not support attributed strings, you have two options:
- Subclass UILabel and override -drawRect:
- Create 2 UILabels, one of which will display the heading, the other showing the rest of your text. You can choose to wrap the two labels into your own view if necessary.
You could use a UIWebView with an HTMLString of <strong>First part</strong> second part