From 6144f31eabb4b8e8c4840d8ebbbfcd94fb6af40a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E5=B0=8F=E5=B8=83?= <13205847+lvbuqigou@user.noreply.gitee.com> Date: Thu, 19 Dec 2024 16:09:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E9=A1=B5=E5=8A=A8=E7=94=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=AA=E8=80=81=E8=99=8E=E6=9C=BA=E7=89=B9=E6=95=88=EF=BC=88?= =?UTF-8?q?=E5=85=88=E5=90=8E=E6=97=B6=E5=B7=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/AnimateNSTextView.swift | 5 ++++- sources/SquirrelPanel.swift | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sources/AnimateNSTextView.swift b/sources/AnimateNSTextView.swift index 314b87e67..648224bc1 100644 --- a/sources/AnimateNSTextView.swift +++ b/sources/AnimateNSTextView.swift @@ -16,6 +16,7 @@ class AnimateNSTextView: NSTextField { var animationDuration: Double = 0.2 var animationInterruptType = "smooth" private var oldTextLayer = CATextLayer() + var i = 0 //转换传入的字符串为CAMediaTimingFunctionName格式 var animationTypeStr: String = "easeOut" { @@ -105,6 +106,7 @@ class AnimateNSTextView: NSTextField { oldLayerAnimation.duration = 0.2 oldLayerAnimation.fillMode = .forwards oldLayerAnimation.isRemovedOnCompletion = true + oldLayerAnimation.timingFunction = CAMediaTimingFunction(name: .easeOut) // 动画缓动函数 oldTextLayer.add(oldLayerAnimation, forKey: nil) @@ -112,9 +114,10 @@ class AnimateNSTextView: NSTextField { let layerAnimation = CABasicAnimation(keyPath: "position.y") layerAnimation.fromValue = self.frame.origin.y - self.frame.height*CGFloat(isTurning) layerAnimation.toValue = self.frame.origin.y // 向上移动20个单位 - layerAnimation.duration = 0.2 + layerAnimation.duration = 0.3 + CGFloat(i) * 0.2 // layerAnimation.fillMode = .forwards layerAnimation.isRemovedOnCompletion = true + layerAnimation.timingFunction = CAMediaTimingFunction(name: .easeIn) // 动画缓动函数 newTextLayer.add(layerAnimation, forKey: nil) diff --git a/sources/SquirrelPanel.swift b/sources/SquirrelPanel.swift index 88d6e8035..e4124e7e4 100644 --- a/sources/SquirrelPanel.swift +++ b/sources/SquirrelPanel.swift @@ -628,7 +628,8 @@ private extension SquirrelPanel { animateNSTextView.animationTypeStr = theme.candidateAnimationType animateNSTextView.animationDuration = theme.candidateAnimationDuration animateNSTextView.animationInterruptType = theme.candidateAnimationInterruptType - animateNSTextView.page = page + animateNSTextView.page = page + animateNSTextView.i = i // animateNSTextView.textContentStorage?.attributedString = lines[i] //如果是NSTextView用这个 animateNSTextView.attributedStringValue = lines[i] //更新视图字符串 // print("更新前lines[i]:[\(lines[i].string)]")