[英]Taking screenshot of iphone device without using UIGetScreenImage() from private API
[英]UIGetScreenImage - Private API
但是,我在應用程序中使用的是UIGetScreenImage,因為大家都知道Apple拒絕使用私有API的應用程序。 我已經研究了使用拍照實現此目的的其他方法,但是您會得到不同大小的圖像以及令人討厭的快照聲音。 Microsoft標簽。 Quickmark和Redalaser都使用UIGetScreenImage(很明顯),但是我想合法地這樣做。 有沒有人有任何建議。 非常感激。
這可能行得通...我認為這是另一個SO問題的答案。
-(UIImage *)captureView:(UIView *)view {
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, screenRect);
[view.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
目前, UIGetScreenImage
是Apple推薦的捕獲屏幕的方法。 這是一種私有方法,但他們在開發人員論壇中表示,除非添加等效的public-API,否則使用它是可以接受的。
更新:從iOS 4開始,不再允許UIGetScreenImage
; 我相信現在已批准的拍照方式是使用AVFoundation框架。
最好的(也是最慢的)方法是向Apple提出功能請求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.