开发者

Code example for iPhone UIGetScreenImage

开发者 https://www.devze.com 2022-12-24 16:59 出处:网络
I\'ve seen a number of开发者_开发百科 posts on UIGetScreenImage, however, not a complete working (short) code example.

I've seen a number of开发者_开发百科 posts on UIGetScreenImage, however, not a complete working (short) code example.

If anyone has a code example, from the prototype definition to an actual call, that would be greatly appreciated.


CGImageRef UIGetScreenImage(void);

....

    CGImageRef screen = UIGetScreenImage();
    UIImage* screenImage = [UIImage imageWithCGImage:screen];
    CGImageRelease(screen); // you need to call this. 
                           // UIGetScreenImage violates the CF memory management rules.
    // Use screenImage as you like.


Recently I needed to integrate taking screenshots into my iOS app. This question comes up pretty high in the search list on StackOverflow. However, since the initial public release of this method, Apple has made UIGetScreenImage private and any call to it will get your app rejected.

Apple made this post on their official forum regarding replacing calls to UIGetScreenImage.

Programmatic screenshots are no longer as simple as they use to be and there are now different ways to take a screenshot depending on the type of image that needs to be acquired.

The above Apple forum post explains how to take an image in each context.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号