是否可以找到UIBarButtonSystemItem的默认图形作为物理图像文件?
答案 0 :(得分:0)
我不知道如何从sdk中取出图像,但你可以通过iphone模拟器将它们打印到磁盘上。只需将您想要的任何UIBarButtonSystemItem添加到导航栏并将其操作指向printImages
- (void)printImages {
UIView *navbar = (UIView *)self.navigationController.navigationBar;
for (UIView *v in navbar.subviews) {
UIGraphicsBeginImageContextWithOptions(v.layer.bounds.size, NO, 0.0);
[v.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [docPaths objectAtIndex:0];
NSString *docPath = [docDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%x.png", arc4random()]];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(viewImage)];
[imageData writeToFile:docPath atomically:YES];
}
}
当你点击按钮时,图像将被写入磁盘〜/ Library / Application Support / iPhone Simulator / x.x / Applications / {crazy-guid-for-app} / Documents /
注意:您需要#import <QuartzCore/QuartzCore.h>
并将QuartzCore.framework添加到您的应用程序中。