gpt4 book ai didi

swift - 如何在swift中将从左到右的动画添加到textlayer

转载 作者:搜寻专家 更新时间:2023-11-01 05:35:52 25 4
gpt4 key购买 nike

我正在尝试快速创建一个视频编辑器。目前,我需要添加一个文本层,我需要在其中从右到左导航文本。下面给出了我使用的代码

let textLayer = CATextLayer()
textLayer.backgroundColor = UIColor.clearColor().CGColor
textLayer.foregroundColor = UIColor.whiteColor().CGColor
textLayer.string = "T E S T"
textLayer.font = UIFont(name: "Helvetica", size: 28)
textLayer.shadowOpacity = 0.5
textLayer.alignmentMode = kCAAlignmentCenter
textLayer.frame = CGRectMake(0, 50, showInBounds.width,showInBounds.height/6)
textLayer.shouldRasterize = true

let parentLayer = CALayer()
let videoLayer = CALayer()
parentLayer.frame = CGRectMake(0, 0, showInBounds.width, showInBounds.height);
videoLayer.frame = CGRectMake(0, 0, showInBounds.width, showInBounds.height);
parentLayer.addSublayer(videoLayer)
parentLayer.addSublayer(textLayer)

mainComposition.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videoLayer, inLayer: parentLayer)
return (mixComposition, mainComposition)

现在,出现了文本,但导航不起作用。请帮忙。提前致谢

最佳答案

我已经使用下面的动画方法解决了这个问题

let animation = CABasicAnimation(keyPath: "transform.translation.x")

关于swift - 如何在swift中将从左到右的动画添加到textlayer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40402184/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com