Skip to content

😂 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PhilCai1993 opened this issue Oct 30, 2015 · 6 comments
Closed

😂 #1

PhilCai1993 opened this issue Oct 30, 2015 · 6 comments

Comments

@PhilCai1993
Copy link

是赵日天啦~

@TBXark
Copy link
Owner

TBXark commented Oct 30, 2015

😂 为什么要会注意到这个小东西

@PhilCai1993
Copy link
Author

  // 小球整体沿着圆弧运动,但是当圆弧运动动画合形变动画叠加在一起的时候,就没有了向心作用,所以就把形变动画放在子 Layer 里面
        let positionAnimation = CAKeyframeAnimation(keyPath: "position")
        positionAnimation.duration = duration
        positionAnimation.beginTime = beginTime
        positionAnimation.additive = true;
        positionAnimation.calculationMode = kCAAnimationPaced;
        positionAnimation.rotationMode = kCAAnimationRotateAuto;
        positionAnimation.path = movePath.CGPath
        positionAnimation.fillMode = kCAFillModeBoth
        positionAnimation.delegate = self
        var point = self.position
        point.x += (styleConfig.smallBubbleSize + styleConfig.bubbleXOffsetSpace) * CGFloat(lastDirection.toBool() ? -1 : 1)
        self.position = point

// 没找到办法在球做完圆弧运动后保持状态的办法,这里只能关掉隐式动画强行改变位置
CATransaction.begin()
CATransaction.setDisableActions(true)
self.opacity = 0
var point = self.position
point.x += (styleConfig.smallBubbleSize + styleConfig.bubbleXOffsetSpace) * CGFloat(lastDirection.toBool() ? -1 : 1)
self.position = point
self.opacity = 1
CATransaction.commit()

改成这样试试看, 好像只是在presentlayer上动画

@TBXark
Copy link
Owner

TBXark commented Oct 30, 2015

之前试过,这样子就没有了圆弧运动了,而是直接水平运动

@PhilCai1993
Copy link
Author

positionAnimation.removedOnCompletion = false呢?
下面的一些删掉:
CATransaction.begin()
CATransaction.setDisableActions(true)
self.opacity = 0
var point = self.position
point.x += (styleConfig.smallBubbleSize + styleConfig.bubbleXOffsetSpace) * CGFloat(lastDirection.toBool() ? -1 : 1)
self.position = point
self.opacity = 1
CATransaction.commit()

但是小球的结果有一点点不太对。。

@TBXark
Copy link
Owner

TBXark commented Nov 2, 2015

实际上是不行的,因为显示动画并没有真正改变 Layer 的位置,第一次看可能没问题,但是第二次运动就能看出问题了. 隐式动画和 UIView 动画能在产生动画效果的同时改变属性.

@PhilCai1993
Copy link
Author

对哦。。。

@TBXark TBXark closed this as completed Aug 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants