views:

67

answers:

1

Why would the default iPhone interface elements, specifically the UISwitch (unmodified) and a UISegmentedControl appear slightly blurred? I have not changed them or called any private APIs. This blurring occurs when I run it both in the simulator and when I load it on my iPod Touch, so I don't think it's a one off drawing glitch. These elements were created via some code (initWithFrame:) not in interface builder. Here is a screenshot of the blurring in the simulator: http://drp.ly/14rS6a

It looks similar on the actual device.

Thanks for your help

+1  A: 

How are you positioning the elements on the UI? I saw this problem with UILabel when I was trying to center the label and the x or y position ended up being a float instead of an int, so it was trying to render the text on a half pixel and it looked very blurry. I truncated everything to an int and it looked normal

OTisler
I'll try that, thanks!
Tom H
I had changed the width of a scroll view within which the elements were being created. I changed the width to an even number, and all the calculations sorted themselves out, so all crisp now. Thank you!
Tom H
Is floor() not available on the iPhone SDK?
Joshua Nozzi
When laying out controls programmatically, `CGRectIntegral` is your friend.
Alex
As is the Core Animation instrument's "Color Misaligned Images" option, which visually highlights non-integral-aligned views and layers.
Brad Larson