Frame geometry macros to improve your UIKit code

I find myself doing more and more dynamic UI layout in iOS apps these days. When elements of a UI need to resize to fit their contents, or move to accommodate other elements, the layout code can get complex and verbose. We’ve developed a set of Objective-C UIKit macros that help make this code more […]

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 […]