增长视图执行动作和缩小视图

时间:2015-05-27 12:16:59

标签: ios swift animation

我使用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)
        }
    }

但它不会那样工作。我该如何解决这个问题?

1 个答案:

答案 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)