I am currently having a minor issue with UILabel objects. In Xcode 4.0.2, I am using Interface Builder to build a view with some right aligned labels stacked vertically. The labels are all identical except for their tag and for the Y coordinates of their frame.
If the text in the labels are all the same length, the rights of the text are happily lined up. However, if the text length is different, the rights of the longer text will be off slightly. This happens both if I change the text property in IB and observe it on the design surface, and if I run the app in either the simulator or on the device and have differing text lengths in the labels. In order to more clearly observe 开发者_C百科this, I changed the background color of a couple of the labels, and it is visible right away once the text lengths are different.
I have tried to change a lot of the properties of the labels to be the same, I have increased the size of the labels, but nothing seems to affect this. The width of the label is far larger than the text that I am trying to place inside.
Here is an example of what I am talking about. In IB, here is what the view looks like with all of the labels having the same text length:
And here is what it looks like if I change the first label's text to 00.00:
Any ideas of what could be causing this?
I believe the reason is because the first character in a word has its x position aligned to integral coordinates, but subsequent characters use the fractional x position (so as to provide for even kerning). By adding an extra zero to the first line, you've changed where the word starts, and so the last zero in your line is at a slightly different fractional position than the other zeros.
Honestly, I wouldn't worry about it. It's a very subtle antialiasing difference.
精彩评论