Skip to content

Instantly share code, notes, and snippets.

@zrxq
Last active December 16, 2015 02:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zrxq/5362898 to your computer and use it in GitHub Desktop.
Save zrxq/5362898 to your computer and use it in GitHub Desktop.
contentCenter CGRect for a CALayer from a resizable UIImage (resizableImageWithCapInsets)
inline static CGRect CGRectCenterRectForResizableImage(UIImage *image) {
return CGRectMake(image.capInsets.left/image.size.width, image.capInsets.top/image.size.height, (image.size.width-image.capInsets.right-image.capInsets.left)/image.size.width, (image.size.height-image.capInsets.bottom-image.capInsets.top)/image.size.height);
}
@PhilCai1993
Copy link

Excellent solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment