复制视图,平行显示

//方法1:
- (void)mirrorTheVideo:(NSInteger)count {
    CAReplicatorLayer *replicatorLayer = (CAReplicatorLayer *)self.playerBackgroundView.layer;
    replicatorLayer.instanceCount = count;
    replicatorLayer.instanceTransform = CATransform3DMakeTranslation(self.playerBackgroundView.frame.size.width/count, 0, 0);
}

//self.playerBackgroundView
//改写 UIView 的层:重写 layerClass 方法
+ (Class)layerClass{
    return [CAReplicatorLayer class];
}
//方法2
- (void)mirrorTheVideo2:(NSInteger)count {
    UIView *avBackView = self.playerBackgroundView;
    UIView *avView = self.playerView;

    avBackView.backgroundColor = [UIColor redColor];
    avView.backgroundColor = [UIColor greenColor];

    CAReplicatorLayer *replicatorLayer = [CAReplicatorLayer layer];
    replicatorLayer.instanceCount = count;
    replicatorLayer.instanceTransform = CATransform3DMakeTranslation(self.playerBackgroundView.frame.size.width/count, 0, 0);
    [avBackView.layer addSublayer:replicatorLayer];

    [replicatorLayer addSublayer:avView.layer];
}
Simulator Screen Shot - iPhone 13 Pro - 2021-12-30 at 11.44.19.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容