Capturing full screenshot with status bar in iOS programmatically

后端 未结 7 2397
执笔经年
执笔经年 2020-12-14 03:45

I am using this code to capture a screenshot and to save it to the photo album.

-(void)TakeScreenshotAndSaveToPhotoAlbum
{
   UIWindow *window = [UIApplicati         


        
7条回答
  •  时光取名叫无心
    2020-12-14 04:41

    The suggested "official" screenshot method doesn't capture status bar (it is not in the windows list of the application). As tested on iOS 5.

    I believe, this is for security reasons, but there is no mention of it in the docs.

    I suggest two options:

    • draw a stub status bar image from resources of your app (optionally update time indicator);
    • capture only your view, without status bar, or trim image afterwards (image size will differ from standard device resolution); status bar frame is known from corresponding property of application object.

提交回复
热议问题