Skip to content

Instantly share code, notes, and snippets.

@BetrayalPromise
Forked from aegzorz/CGRect+Additions.h
Created April 19, 2016 08:17
Show Gist options
  • Select an option

  • Save BetrayalPromise/9b83fff837c859a1a938de9b88b21555 to your computer and use it in GitHub Desktop.

Select an option

Save BetrayalPromise/9b83fff837c859a1a938de9b88b21555 to your computer and use it in GitHub Desktop.
Some functions for dealing with CGRects
static __inline__ CGRect CGRectFromCGSize( CGSize size ) {
return CGRectMake( 0, 0, size.width, size.height );
};
static __inline__ CGRect CGRectMakeWithCenterAndSize( CGPoint center, CGSize size ) {
return CGRectMake( center.x - size.width * 0.5, center.y - size.height * 0.5, size.width, size.height );
};
static __inline__ CGRect CGRectMakeWithOriginAndSize( CGPoint origin, CGSize size ) {
return CGRectMake( origin.x, origin.y, size.width, size.height );
};
static __inline__ CGPoint CGRectCenter( CGRect rect ) {
return CGPointMake( CGRectGetMidX( rect ), CGRectGetMidY( rect ) );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment