Using fractional pixels to position UIImageViews

Posted by on Aug 8, 2011 in iOS | No Comments

When centering content vertically and/or horizontally in a view, I often use a simple formula to calculate the x/y values for the content’s frame: image.frame.origin.y =    (container.frame.size.height – image.frame.size.height)/2 The problem with using this formula for UIImageViews is that, if one or more of the dimensions is an odd value, the result will be […]