All Questions

1882
votes
45answers
552635 views

Vertically align text to top within a UILabel

I have a UILabel with space for two lines of text. Sometimes, when the text is too short, this text is displayed in the vertical center of the label. How do I vertically align the text to always be a...
283
votes
33answers
230233 views

Adjust UILabel height depending on the text

Consider I have the following text in a UILabel (a long line of dynamic text): Since the alien army vastly outnumbers the team, players must use the post-apocalyptic world to their advantage, such...
162
votes
25answers
134746 views

Create tap-able "links" in the NSAttributedString of a UILabel?

I have been searching this for hours but I've failed. I probably don't even know what I should be looking for. Many applications have text and in this text are web hyperlinks in rounded rect. When I ...
246
votes
30answers
206441 views

UILabel text margin

I'm looking to set the left inset/margin of a UILabel and can't find a method to do so. The label has a background set so just changing its origin won't do the trick. It would be ideal to inset the te...
191
votes
16answers
161142 views

How do I make an attributed string using Swift?

I am trying to make a simple Coffee Calculator. I need to display the amount of coffee in grams. The "g" symbol for grams needs to be attached to my UILabel that I am using to display the amount. The ...
143
votes
13answers
84774 views

UILabel sizeToFit doesn't work with autolayout ios6

How am I supposed to configure programmatically (and in which method) a UILabel whose height depends on its text? I've been trying to set it up using a combination of Storyboard and code, but to no a...
60
votes
10answers
67146 views

iPhone - UILabel containing text with multiple fonts at the same time

I am looking for a way to use a UILabel (or something similar) to display something like this: Tom: Some message. It is like how it's done in for example the Facebook app to display the "what's on y...
76
votes
18answers
109173 views

Underline text in UIlabel

How can I underline a text that could be multiple lines of string? I find some people suggest UIWebView, but it is obviously too heavy a class for just text rendering. My thoughts was to figure out t...
386
votes
23answers
309859 views

Multiple lines of text in UILabel

Is there a way to have multiple lines of text in UILabel like in the UITextView or should I use the second one instead?
87
votes
3answers
60703 views

Figure out size of UILabel based on String in Swift

I am trying to calculate the height of a UILabel based on different String lengths. func calculateContentHeight() -> CGFloat{ var maxLabelSize: CGSize = CGSizeMake(frame.size.width - 48, CGFlo...

Previous Next