6
A
回答
21
UIGraphicsBeginImageContext(myView.frame.size);
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data=UIImagePNGRepresentation(viewImage);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *strPath = [documentsDirectory stringByAppendingPathComponent:@"myimage.png"];
[data writeToFile:strPath atomically:YES];
0
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(YourView.frame.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(keyWindow.bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[keyWindow.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
UIGraphicsEndImageContext();
相關問題
- 1. 將.png圖像轉換爲.gif圖像
- 2. 將PNG圖像轉換爲視頻
- 3. pgmagick:將圖像轉換爲PNG格式
- 4. 將圖像轉換爲png上傳
- 5. 將SVG轉換爲PNG圖像
- 6. 將所有圖像轉換爲PNG
- 7. 將SVG轉換爲圖像(PNG,JPG)
- 8. 將base64圖像數據轉換爲png?
- 9. 將YUV圖像格式轉換爲PNG
- 10. PHP將POST圖像轉換爲PNG
- 11. 嘗試將SVG轉換爲PNG圖像
- 12. 將png轉換爲jpeg(轉換後的圖像質量)
- 13. 如何將png圖像字符串數據轉換爲png?
- 14. 如何將base64-encode圖像轉換爲imagemagick中的PNG圖像?
- 15. 如何將base64 svg圖像轉換爲base64圖像png
- 16. 如何將base64_encode png圖像轉換爲簡單圖像
- 17. 將PVR.CCZ圖像轉換爲PNG以編輯圖像。
- 18. 將透明度的png圖像轉換爲jpg破壞圖像
- 19. 將jpeg圖像轉換爲透明PNG圖像
- 20. 從png創建圖像,轉換爲base64
- 21. 將PNG圖像轉換爲像素灰度值特徵向量
- 22. 我將如何將PNG圖像轉換爲字節數組?
- 23. 如何使用ogr2ogr將S57圖表轉換爲PNG圖像
- 24. 將Google圖表轉換爲PNG圖像與下載
- 25. 如何將位圖圖像轉換爲Windows Phone 7中的png?
- 26. iOS - 如何將png圖像轉換爲4位位圖灰度?
- 27. 將PNG圖像轉換爲SVG /矢量圖
- 28. 如何將視圖轉換爲PNG?
- 29. 將.gif圖片從url轉換爲.png
- 30. 將UIView圖層轉換爲UIImage
ü要獲取的UIView的屏幕截圖? –
你想要圖像轉換成.png格式或屏幕捕獲 –