8
A
回答
19
UIGraphicsBeginImageContext(yourView.bounds.size);
[yourView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
注意:您需要爲此包含QuartzCore。
1
CGRect myRect =CGRectMake(0, 0, 300, 300);// [self.view bounds];
UIGraphicsBeginImageContext(myRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, myRect);
[self.view.layer renderInContext:ctx];
UIImage *image1 = UIGraphicsGetImageFromCurrentImageContext();
相關問題
- 1. Swift從UIView的圖層獲取UIImage
- 2. 從UIImage獲取底層NSData *
- 3. 如何從MotionEvent獲取底層視圖?
- 4. Bitbake從github回購層獲取圖層
- 5. 無法從圖像獲取UIImage NSURL
- 6. NSView - 獲取超視圖層次結構
- 7. 如何從業務層裝配中獲取視圖的路徑?
- 8. 全屏UIImage視圖
- 9. 如何從WPF Prism中的另一個視圖獲取視圖/區域的底層視圖模型
- 10. 從url獲取視圖
- 11. 笨獲取從視圖
- 12. 從XML中獲取視圖
- 13. 如何從任何其他視圖控制器獲取視圖控制器的詳細視圖層次結構?
- 14. 如何從PSD文件獲取圖層?
- 15. 從網格視圖獲取圖像
- 16. 如何獲取uiImage視圖的觸摸事件?
- 17. 從屏幕視圖中查看UIImage
- 18. 獲取滾動視圖內的視圖
- 19. 獲取CIImage從UIImage的(SWIFT)
- 20. 如何從縮放圖像中的UITapGestureRecognizer獲取UIImage的座標?
- 21. 視圖層次
- 22. 給定圖層的對象。我如何獲得iPhone中的圖層視圖?
- 23. 從視頻網址獲取視頻的縮略圖圖像
- 24. UIImage視圖編碼爲base64
- 25. 從視圖獲取不同的值
- 26. 從MVVM中的視圖獲取數據?
- 27. 從其名稱獲取視圖的ID
- 28. CAAnimation層取消視圖的previos轉換
- 29. 將UIImageView圖層導出到UIImage
- 30. 圖片視圖VS UIImage View Xcode placement