4 ms·
"there must be an iOS equivalent of the <strong> tag, right? Apparently not." Just use three labels, with the middle label set to bold.
by 10dpd 14y ago
"there must be an iOS equivalent of the <strong> tag, right? Apparently not."
Just use three labels, with the middle label set to bold.
- unwind 14y agoDoesn't that make you "too" responsible for the spacing? Is it as easy to get the distance between two labels to be exactly one space? Or can you include trailing/leading spaces in the strings, and have them automatically laid out? Note: I (obviously) don't program for iOS, but the above recommendation would be non-trivial in the toolkit I know best (GTK+) which is why I'm curious.
- div 14y agoIt does. Starting from iOS 6, UILabels can display attributed strings out of the box. If you need to support iOS < 6, the best approach is to use TTTAttributedLabel or NIAttributedLabel.
- bennyg 14y agoSure it makes you responsible, but this is a very, very easy solution to the problem. Obviously, for dynamically iterating, an NSAttributedString is the "best" solution. You just line them up in interface builder and use your eyes and the arrow cursor to get it right. For static text on a non-changing screen like this, this solution is probably the best.
- duopixel 14y agoIf the app were to be displayed in other language it would mess up the word spacing.
- muzzamike 14y agoAt least you wouldn't need a new image for each new language.
- chrisdevereux 14y agoIn iOS 6 at least, UILabel supports attributed strings. I have no idea what took so long either.
- potatolicious 14y agoOr, really, how thick the API is around it. Attributed strings won't see very wide adoption until someone (preferably Apple?) gives us an easy to use markup language around it. Manually screwing around with NSRange's is not the way forward.