Reputation: 33048
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 ?
Upvotes: 6
Views: 3231
Reputation: 44730
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.
Upvotes: 7
Reputation: 112857
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);
Upvotes: 4