0
是否可以找到UIBarButtonSystemItem的默認圖形作爲物理圖像文件?默認圖形
是否可以找到UIBarButtonSystemItem的默認圖形作爲物理圖像文件?默認圖形
即時通訊不知道如何從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];
}
}
當你點擊按鈕上的圖像會在〜/庫/應用程序支持/ iPhone模擬器/ XX /應用程序被寫入到磁盤
/{crazy-guid-for-app}/Documents/
注意:您需要#import <QuartzCore/QuartzCore.h>
並將QuartzCore.framework添加到您的應用程序中。