Kaynağa Gözat

feat: 调整点赞动画效果

陈文艺 7 saat önce
ebeveyn
işleme
02444713aa

+ 12 - 7
Lanu/Views/Profile/Profile/LNProfileUserInfoView.swift

@@ -96,6 +96,7 @@ extension LNProfileUserInfoView {
         likeIc.layer.removeAllAnimations()
         likeContainer.layer.removeAnimation(forKey: "likeRing")
         likeContainer.layer.removeAnimation(forKey: "likeBurst")
+        likeContainer.layoutIfNeeded()
         
         likeIc.transform = CGAffineTransform(scaleX: 0.72, y: 0.72)
         UIView.animate(withDuration: 0.18, delay: 0, usingSpringWithDamping: 0.52, initialSpringVelocity: 0.6) {
@@ -106,9 +107,12 @@ extension LNProfileUserInfoView {
             }
         }
         
-        let center = CGPoint(x: likeIc.center.x, y: likeIc.center.y)
+        let center = likeContainer.convert(
+            CGPoint(x: likeIc.bounds.midX, y: likeIc.bounds.midY),
+            from: likeIc
+        )
         let ringLayer = CAShapeLayer()
-        ringLayer.path = UIBezierPath(ovalIn: CGRect(x: center.x - 10, y: center.y - 10, width: 20, height: 20)).cgPath
+        ringLayer.path = UIBezierPath(ovalIn: CGRect(x: center.x - 13, y: center.y - 13, width: 26, height: 26)).cgPath
         ringLayer.fillColor = UIColor.clear.cgColor
         ringLayer.strokeColor = UIColor.fill_6.withAlphaComponent(0.35).cgColor
         ringLayer.lineWidth = 2
@@ -116,7 +120,7 @@ extension LNProfileUserInfoView {
         
         let ringScale = CABasicAnimation(keyPath: "transform.scale")
         ringScale.fromValue = 0.3
-        ringScale.toValue = 1.9
+        ringScale.toValue = 2.2
         
         let ringOpacity = CABasicAnimation(keyPath: "opacity")
         ringOpacity.fromValue = 0.9
@@ -137,7 +141,8 @@ extension LNProfileUserInfoView {
         CATransaction.commit()
         
         let burstLayer = CAReplicatorLayer()
-        burstLayer.frame = likeContainer.bounds
+        burstLayer.bounds = CGRect(x: 0, y: 0, width: 52, height: 52)
+        burstLayer.position = center
         burstLayer.instanceCount = 6
         burstLayer.instanceTransform = CATransform3DMakeRotation(.pi * 2 / 6, 0, 0, 1)
         burstLayer.instanceDelay = 0.015
@@ -145,13 +150,13 @@ extension LNProfileUserInfoView {
         
         let dotLayer = CALayer()
         dotLayer.backgroundColor = UIColor.fill_6.cgColor
-        dotLayer.frame = CGRect(x: center.x - 1.5, y: center.y - 17, width: 3, height: 7)
-        dotLayer.cornerRadius = 1.5
+        dotLayer.frame = CGRect(x: burstLayer.bounds.midX - 2, y: 2, width: 4, height: 9)
+        dotLayer.cornerRadius = 2
         burstLayer.addSublayer(dotLayer)
         
         let burstMove = CABasicAnimation(keyPath: "transform.translation.y")
         burstMove.fromValue = 0
-        burstMove.toValue = -9
+        burstMove.toValue = -13
         
         let burstScale = CABasicAnimation(keyPath: "transform.scale")
         burstScale.fromValue = 0.6