简体   繁体   English

CATextLayer字体大小动画速度

[英]CATextLayer font size animation velocity

I have a little annoying problem. 我有一个烦人的问题。 I have a CATextLayer, which I use to display the placeholder of UITextView. 我有一个CATextLayer,用于显示UITextView的占位符。 The fact is that when animating this layer, its velocity is too small and I see "jumps" during the animation. 事实是,在为该层设置动画时,其速度太小,在动画过程中我会看到“跳跃”。 I use UIView.animate with a velocity parameter, but it ignores it. 我使用带有速度参数的UIView.animate,但它忽略了它。

GIF FILE: GIF文件:

DispatchQueue.main.async {
    UIView.animate(
        withDuration: 0.2,
        delay: 0.0,
        usingSpringWithDamping: 1.0,
        initialSpringVelocity: 1.0, // Ignore any options
        options: .curveEaseOut,
        animations: {
            self.floatingLabel?.fontSize = 10
            self.floatingLabel?.frame = self.toggledFloaterFrame
        })
}

What could be the problem? 可能是什么问题呢?

Animation of the fontSize property is not possible. 无法对fontSize属性进行动画处理。 Try using the transform to scale it down. 尝试使用transform将其缩小。

You can use CGAffineTransform(scaleX: scale, y: scale) with scale being 10/self.floatingLabel.fontSize and CGAffineTransform.identity to go back to full size. 您可以使用CGAffineTransform(scaleX: scale, y: scale)scale10/self.floatingLabel.fontSizeCGAffineTransform.identity返回完整大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM