UIGetScreenImage - 私有API

时间:2009-12-04 20:45:05

标签: iphone objective-c iphone-privateapi

我在我的应用程序中使用了UIGetScreenImage,因为每个人都知道Apple拒绝使用私有API的应用程序。我已经研究了使用takepicture执行此操作的其他方法,但是您可以获得不同大小的图像以及恼人的快照声音。微软标签。 Quickmark和Redalaser都使用UIGetScreenImage(很明显),但我想合法地做到这一点。有没有人有任何建议。非常感谢。

3 个答案:

答案 0 :(得分:3)

这可能有用......我认为这是另一个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; 
}

答案 1 :(得分:3)

UIGetScreenImage目前是Apple推荐的捕捉屏幕的方式。这是一种私有方法,但是他们已经在开发人员论坛中声明,在添加公共API等效项之前,使用它是可以接受的。

更新:不再允许UIGetScreenImage,从iOS 4开始;我相信批准的拍照方式现在正在使用AVFoundation框架。

答案 2 :(得分:0)

最好(也是最慢)的事情是在Apple提交功能请求。