//方法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