iOS.Lover
iOS.Lover

Reputation: 6051

ReplayKit square recording

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!

Upvotes: 1

Views: 1459

Answers (2)

ahbou
ahbou

Reputation: 4928

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];

Upvotes: 3

technerd
technerd

Reputation: 14504

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.

Upvotes: 0

Related Questions