Following phenomenon: my text is "Search". I create a UILabel
of SmallSystemFontSize and call sizeToFit:
.
The result is 39 units wide and the text looks kind of blurry. If I adjust the width to 40 it looks perfect.
I read that the text gets blurry if you hit sub pixels, meaning the width would be something like 39.5, but it seems it has to be even.
Can somebody confirm or even explain what is going on ?
A view that displays one or more lines of informational text.
If you set numberOfLines to 0 (and the label to word wrap), the label will automatically wrap and use as many of lines as needed. If you're editing a UILabel in IB, you can enter multiple lines of text by pressing option + return to get a line break - return alone will finish editing.
In my case, having set shouldRasterize = YES
on the CGLayer of the UILabel's superview was the culprit. Removing that line made the text nice and crisp.
UIView
items are positioned by their center which for a size that is odd is on a half pixel, 19.5 for a width of 39.. This alignment causes pixel averaging that causes the fuzziness.
One way is to make it an even width.
Another is to place it by the center at an even point use:
@property(nonatomic) CGPoint center
Example, for a desired position of label;
at (10, 10, 39, 19) one could use:
label.center = CGPointMake(50, 20);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With