Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#ifndef __CGRECT_MACROS__
#define __CGRECT_MACROS__
#define CGRectX(rect) rect.origin.x
#define CGRectY(rect) rect.origin.y
#define CGRectWidth(rect) rect.size.width
#define CGRectHeight(rect) rect.size.height
#define CGRectSetSize(rect, w, h) CGRectMake(CGRectX(rect), CGRectY(rect), w, h)
#define CGRectSetOrigin(rect, x, y) CGRectMake(x, y, CGRectWidth(rect), CGRectHeight(rect))
#define CGRectSetWidth(rect, w) CGRectSetSize(rect, w, CGRectHeight(rect))
#define CGRectSetHeight(rect, h) CGRectSetSize(rect, CGRectWidth(rect), h)
#define CGRectSetX(rect, x) CGRectSetOrigin(rect, x, CGRectY(rect))
#define CGRectSetY(rect, y) CGRectSetOrigin(rect, CGRectX(rect), y)
#endif /* __CGRECT_MACROS__ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment