Created
January 11, 2015 06:53
-
-
Save donpark/7549a1a2a5f7eef7fbea to your computer and use it in GitHub Desktop.
CALayer with resizable image
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
- (CALayer*)layerFromResiableImage:(UIImage*)image { | |
CGSize size = [image size]; | |
UIEdgeInsets insets = [image capInsets]; | |
CALayer *layer = [CALayer layer]; | |
[layer setContents:(id)[image CGImage]]; | |
layer.contentsCenter = CGRectMake(insets.left / size.width, insets.top / size.height, | |
1.0/size.width, 1.0 / size.height); | |
return layer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment