我使用JHChainableAnimations来增大(缩放)视图设置新值,然后再将视图缩小(缩放)到原始大小。
我试着这样做:
var isGrowing = true
self.badgeView?.transformScale()(2).animate()(3)
self.badgeView?.animationCompletion = {
if isGrowing {
isGrowing = false
self.badgeView?.badgeText = "\(self.selectionCounter)"
self.badgeView?.transformScale()(1).animate()(3)
}
}
但它不会那样工作。我该如何解决这个问题?
答案 0 :(得分:2)
在JHChainableAnimations中的示例中,您必须在开始动画之前设置animationCompletion,而animationCompletion类型必须是JHAnimationCompletion
var isGrowing = true
self.badgeView?.animationCompletion = JHAnimationCompletion(){
if isGrowing {
isGrowing = false
self.badgeView?.badgeText = "\(self.selectionCounter)"
self.badgeView?.transformScale()(0.5).animate()(3)
}
}
self.badgeView?.transformScale()(2).animate()(3)