Re:Surprises When Designing An iPhone App
by unwind on Tuesday December 11, 2012 @12:53PM
(#4905686)
Doesn'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.
It 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.
Re:Surprises When Designing An iPhone App
by bennyg on Tuesday December 11, 2012 @03:15PM
(#4906564)
Sure 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.
Re:Surprises When Designing An iPhone App
by chrisdevereux on Tuesday December 11, 2012 @01:04PM
(#4905761)
In iOS 6 at least, UILabel supports attributed strings. I have no idea what took so long either.
Re:Surprises When Designing An iPhone App
by potatolicious on Tuesday December 11, 2012 @02:20PM
(#4906235)
Or, 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.
Just use three labels, with the middle label set to bold.