Saturday, June 19, 2010

Don't Draw At Fractional Pixel Locations

In the Objective-C Cocoa and Cocoa Touch APIs positions and sizes of UI elements are specified in terms of CGFloats but as I recently discovered problems can occur if you use non-integral values.

One symptom you may find is that with anti-aliasing on the text of a UILabel will appear blurry if the position is set with a fractional value.

The function CGRectIntegral() can help with this.

No comments: