UIImage
Method :
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight
.
Here the stretchable area is forced to be a single pixel high/wide.
I can not set the stretchable area, so I want to know: is there a UIImage category to do that?
After I googled, I found a lib.
Question: Is there a nine-patch loader for iPhone?
Announcement: http://blog.tortuga22.com/2010/05/31/announcing-tortuga-22-ninepatch/
This is a source pic, and I want to stretch the inside gray rect.
Thanks in advance.
In Android Studio, right-click the PNG image you'd like to create a NinePatch image from, then click Create 9-patch file. Type a file name for your NinePatch image, and click OK. Your image will be created with the . 9.
The nine patch images have extension as. 9. png. It allows extension in 9 ways, i.e. 4 corners that are unscaled, 4 edges that are scaled in 1 axis, and the middle one that can be scaled into both axes.
Creating 9 patch background image using Photoshop:Draw the images in a regular way as you use to do in Photoshop. Make the 1px spacing around the image from all sides. And also make sure that the image doesn't have anything in this 1px area & has 100% transparency. Otherwise 9patch image will not work.
A 9 patch image is a regular png (. PNG) image which is needful for android app developers where they require to wrap any content within a background image without pixelating the background image.
One way to achieve this is using the below approach,
UIImage * backgroundImg = [UIImage imageNamed:@"bg.png"];
backgroundImg = [backgroundImg resizableImageWithCapInsets:UIEdgeInsetsMake(2,2, 2, 2)];
[imgView setImage: backgroundImg];
UIEdgeInsetsMake(2,2, 2, 2) is the amount of pixels you want unstretchable.
You can achieve nine patch with Tortuga22 software
You can find source from this GitHub here
Use it like this
[btnSubmit setImage: [TUNinePatchCache imageOfSize:[btnSubmit bounds].size
forNinePatchNamed:@"imgNormalBackground"]
forControlState:UIControlStateNormal];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With