ReplayKit方形录音

时间:2016-01-01 09:23:00

标签: ios objective-c replaykit

我想知道有没有办法强制重放套件只能在方形模式下记录部分屏幕?当前的API似乎记录了整个屏幕!

2 个答案:

答案 0 :(得分:3)

ReplayKit记录屏幕上的所有内容,豁免系统提示和对话框。

然而,您可以将另一个UIWindow覆盖在主要UIWindow的顶部,并将遮罩应用于空的UIView以隐藏部分屏幕并强制进行方形录制。

最终录制的帧率仍然等于屏幕。

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

答案 1 :(得分:0)

目前,ReplayKit框架无法根据屏幕尺寸提供屏幕录制的自定义。所以你必须记录GamePlay的整个屏幕。

相关问题