NinePatch image parser and render framework for iOS & macOS
- parse png's binary data to get its chunk data
- slice image according its npTc chunk, then draw them in rule
- NinePatchImageView has its contentView like UITableViewCell, where you can place any UI object
- support flip horizontally and vertically
- support muliple platform
- support auto layout
- iOS 9.0+
- macOS 10.11+
The preferred installation method is with CocoaPods. Add the following to your Podfile
:
pod 'NinePatchKit'
Copy NinePatchUtils directory in your project
#import <NinePatchKit/NinePatchKit.h>
...
NSString * path = [[NSBundle mainBundle] pathForResource:@"YourNinePatchImageName" ofType:@"png"];
NinePatchImageView * imageView = [[NinePatchImageView alloc] init];
imageView.showImage = [NinePatchUtils imageWithContentsOfFile:path];
[imageView.contentView addSubview:CustomView]; // add subview to contentView
- Placement of nine-patch pictures
- You can place nine-patch pictures in bundle, Data Set and other places besides Image Set. During the construction, all png pictures in Image Set will be optimized by implanting a CgBI chunk, and some chunks will be removed, so the format of nine-patch pictures will be damaged and cannot be parsed.
NinePatchKit
is MIT-licensed.