1.我在正方形的区域里显示了本地的视频,当我关闭本地摄像头后修改了这个显示视频的UI的frame,我吧它改小了。
2.再次显示本地视频的时候除了在我指定的区域显示了视频外,在原来的区域类还遗留了之前关闭视频时最后一帧的图像。 我希望蓝色框中搞得区域也为灰色
3.我现在想清空这最后一帧的图像,请问我应该怎么处理呢?
我试过 removeFromSuperLayer 和 removeFromSuperView 以及向这个显示视频的UI上添加一层view 但是都没有达到效果。
下面是我的效果图片
下面是我的核心代码:
elf.localVideoSurface = [AVCaptureVideoPreviewLayer layerWithSession: (AVCaptureSession*)session];
self.localVideoSurface.frame = CGRectMake(0, 0, self.theLocalView.frame.size.width, self.theLocalView.frame.size.height);
self.localVideoSurface.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.theLocalView.layer addSublayer:self.localVideoSurface];
My problem has been solved. However, the method is not to clear the image rendered on the previous layer on the UIView, but to render a new layer of UIView on top of this, using this method to overwrite the previous layer.
The code is as follows:
//Overwrite the last frame image that stays on theLocalView when closing the video