我想实现这种类型的动画。请检查此 URL
https://www.dropbox.com/s/gz9vfy5refsh7a5/Screen.mov?dl=0
我正在添加我在项目中使用的代码,在该项目中我使用 Core Graphics 渲染带有动画的文本,但我无法为上述链接中显示的文本设置动画
这是我用来在屏幕上呈现文本的代码
let context = UIGraphicsGetCurrentContext()!
context.saveGState()
context.setAlpha(noLightText)
let nOLIGHTRect = CGRect(x: 145.66, y: 590, width: 449.38, height: 125)
let nOLIGHTStyle = NSMutableParagraphStyle()
nOLIGHTStyle.alignment = .center
let nOLIGHTFontAttributes = [
.font: UIFont(name: "Futura-CondensedExtraBold", size: 96)!,
.foregroundColor: nOLIGHTColor,
.paragraphStyle: nOLIGHTStyle,
] as [NSAttributedStringKey: Any]
"NO LIGHT".draw(in: nOLIGHTRect, withAttributes: nOLIGHTFontAttributes)
context.restoreGState()
//// LOW LIGHT Drawing
context.saveGState()
context.setAlpha(_0)
let lOWLIGHTRect = CGRect(x: 145.94, y: 590, width: 449.38, height: 125)
let lOWLIGHTStyle = NSMutableParagraphStyle()
lOWLIGHTStyle.alignment = .left
let …Run Code Online (Sandbox Code Playgroud)