Last active
December 16, 2015 02:29
-
-
Save zrxq/5362898 to your computer and use it in GitHub Desktop.
contentCenter CGRect for a CALayer from a resizable UIImage (resizableImageWithCapInsets)
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
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent solution!