我在视频图层的顶部和后面制作带有图形的视频合成。问题是我无法将视频图层背景颜色设置为清晰(透明),它始终显示黑色背景颜色。我想在它背后展示一些图形。这是代码。我将视频层移动了-200px只是为了确保显示它背后的图形。如何设置视频图层以显示透明背景?
var backLayer = new CALayer
{
Contents = s.CGImage,
BackgroundColor = UIColor.White.CGColor,
Bounds = new CGRect(0, 0, size.Width, size.Height),
Frame = new CGRect(0, 0, size.Width, size.Height),
Hidden = false
};
var animationLayer = new CALayer { Contents = s.CGImage };
animationLayer.BackgroundColor = UIColor.Clear.CGColor;
animationLayer.Bounds = new CGRect(size.Width - 100, 50, 50, 50);
animationLayer.Frame = new CGRect(size.Width - 100, 50, 50, 50);
animationLayer.Hidden = false;
var videoLayer = new CALayer();
videoLayer.BackgroundColor = UIColor.Clear.CGColor;
videoLayer.ShadowColor = UIColor.Clear.CGColor;
videoLayer.BorderColor = UIColor.Clear.CGColor;
videoLayer.Frame = new CGRect(0, -200, size.Width, size.Height);
videoLayer.Bounds = new CGRect(0, -200, size.Width, size.Height);
parentLayer.AddSublayer(backLayer);
parentLayer.AddSublayer(videoLayer);
parentLayer.AddSublayer(animationLayer);
parentLayer.BackgroundColor = UIColor.Clear.CGColor;
videoComposition.AnimationTool = AVVideoCompositionCoreAnimationTool.FromLayer(videoLayer, parentLayer);