1

I was wondering is there any way to force replaykit to record only a part of the screen in square mode? The current API seems to record the whole screen!

Jared Thomas
  • 110
  • 7
iOS.Lover
  • 5,923
  • 21
  • 90
  • 162
  • The guy at wwdc said something about specifying another UIWindow for a similar purpose. Not sure if that UIWindow can be square or if it has to be full screen but I guess the purpose is to only record certain parts. – Jonny Apr 07 '16 at 03:47

2 Answers2

3

ReplayKit records everything on the screen exempt system prompts and dialogs.

You can however overlay another UIWindow on top of your main one and apply a mask to an empty UIView to hide parts of the screen and force a square recording.

The frame ratio of the final recording will still be equal to the screen though.

    _overlayWindow = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; //Full sized window
    _overlayWindow.backgroundColor =  [UIColor clearColor];
    _overlayWindow.userInteractionEnabled = false;
    _overlayWindow.hidden = NO;

UIView *maskedView = [[UIView alloc] initWithFrame:_overlayWindow.bounds];

    // Create a mask layer 
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    CGRect maskRect = CGRectMake(0, 0, 200, 200);

    // Create a path with the rectangle in it.
    CGPathRef path = CGPathCreateWithRect(maskRect, NULL);

    maskLayer.path = path;
    // Set the mask of the view.
    maskedView.layer.mask = maskLayer;

[_overlayWindow addSubview:maskedView];
ahbou
  • 4,710
  • 23
  • 36
0

At the moment ReplayKit framework does not provide customisation of Screen Recording in terms of Screen size. So you have to record whole screen of GamePlay.

technerd
  • 14,144
  • 10
  • 61
  • 92