Last active
December 13, 2015 18:29
-
-
Save nuthinking/4955965 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#import <CoreGraphics/CoreGraphics.h> | |
CGRect CGRectCopy(CGRect rect); | |
CGRect CGRectCopyWithX(CGRect rect, CGFloat x); | |
CGRect CGRectCopyWithY(CGRect rect, CGFloat y); | |
CGRect CGRectCopyWithWidth(CGRect rect, CGFloat width); | |
CGRect CGRectCopyWithHeight(CGRect rect, CGFloat height); | |
CGRect CGRectMakeWithSize(CGSize size); | |
CGRect CGRectMakeWithPointAndSize(CGPoint point, CGSize size); | |
void CGRectMoveToY(CGRect *rect, CGFloat y); | |
void CGRectMoveToX(CGRect *rect, CGFloat x); | |
void CGRectTranslate(CGRect *rect, CGFloat dx, CGFloat dy); | |
void CGRectResizeToWidth(CGRect *rect, CGFloat width); | |
void CGRectResizeToHeight(CGRect *rect, CGFloat height); |
This file contains hidden or 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
#import "CocoaExtensions.h" | |
CGRect CGRectCopy(CGRect rect) | |
{ | |
CGRect res; | |
res.origin = rect.origin; | |
res.size = rect.size; | |
return res; | |
} | |
CGRect CGRectCopyWithX(CGRect rect, CGFloat x) | |
{ | |
CGRect res; | |
res.origin = CGPointMake(x, rect.origin.y); | |
res.size = rect.size; | |
return res; | |
} | |
CGRect CGRectCopyWithY(CGRect rect, CGFloat y) | |
{ | |
CGRect res; | |
res.origin = CGPointMake(rect.origin.x, y); | |
res.size = rect.size; | |
return res; | |
} | |
CGRect CGRectCopyWithWidth(CGRect rect, CGFloat width) | |
{ | |
CGRect res; | |
res.origin = rect.origin; | |
res.size = CGSizeMake(width, rect.size.height); | |
return res; | |
} | |
CGRect CGRectCopyWithHeight(CGRect rect, CGFloat height) | |
{ | |
CGRect res; | |
res.origin = rect.origin; | |
res.size = CGSizeMake(rect.size.width, height); | |
return res; | |
} | |
CGRect CGRectMakeWithSize(CGSize size) | |
{ | |
CGRect rect; | |
rect.size = size; | |
return rect; | |
} | |
CGRect CGRectMakeWithPointAndSize(CGPoint point, CGSize size) | |
{ | |
CGRect rect; | |
rect.origin = point; | |
rect.size = size; | |
return rect; | |
} | |
void CGRectMoveToY(CGRect *rect, CGFloat y) | |
{ | |
rect->origin = CGPointMake(rect->origin.x, y); | |
} | |
void CGRectMoveToX(CGRect *rect, CGFloat x) | |
{ | |
rect->origin = CGPointMake(x, rect->origin.y); | |
} | |
void CGRectTranslate(CGRect *rect, CGFloat dx, CGFloat dy) | |
{ | |
rect->origin = CGPointMake(rect->origin.x + dx, rect->origin.y + dy); | |
} | |
void CGRectResizeToWidth(CGRect *rect, CGFloat width) | |
{ | |
rect->size = CGSizeMake(width, rect->size.height); | |
} | |
void CGRectResizeToHeight(CGRect *rect, CGFloat height) | |
{ | |
rect->size = CGSizeMake(rect->size.width, height); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment