开发者

Taking a screenshot in-app then putting it in a UIImageView does so at normal resolution

After zooming the iOS simulator up to 100%, i've noticed that my icons which are made by the app through taking a 'screenshot' of a view using this code are in normal resolution, whereas everything else appears to be in retina resolution:

UIGraphicsBeginImageContext(rect.size);
[object.la开发者_开发问答yer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Any ideas how to make it be in retina resolution?


UIGraphicsBeginImageContext() is not Retina display-aware.

On iOS 4, you'll need to use UIGraphicsBeginImageContextWithOptions() instead, passing 0 as the last argument to have iOS automatically scale it based on the device's screen resolution:

UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
[object.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜