Created
September 25, 2013 10:31
-
-
Save shaps80/6697830 to your computer and use it in GitHub Desktop.
CGRectDivide with Padding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CGRectDivideWithPadding(CGRect rect, CGRect *slide, CGRect *remainder, CGFloat amount, CGFloat padding, CGRectEdge edge) | |
{ | |
CGRect rect1, rect2; | |
CGRectDivide(rect, &rect1, &rect2, amount, edge); | |
if (edge == CGRectMaxXEdge || edge == CGRectMaxYEdge) | |
{ | |
CGRect tmp = rect1; | |
rect1 = rect2; | |
rect2 = tmp; | |
} | |
(edge == CGRectMaxXEdge || edge == CGRectMinXEdge) ? (rect1.size.width -= padding / 2) : (rect1.size.height -= padding / 2); | |
(edge == CGRectMaxXEdge || edge == CGRectMinXEdge) ? (rect2.origin.x += padding / 2) : (rect2.origin.y += padding / 2); | |
(edge == CGRectMaxXEdge || edge == CGRectMinXEdge) ? (rect2.size.width -= padding / 2) : (rect2.size.height -= padding / 2); | |
*slide = rect1; | |
*remainder = rect2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment