UIPushBehavior在swift中

时间:2016-09-06 23:26:32

标签: ios swift descendant uidynamicanimator uipushbehavior

我想在Swift中实现一个UIPushBehavior,但我总是得到以下错误:...查看项目UIImageView应该是UIDynamicAnimator中参考视图的后代......

我将行为和行为的视图添加到动画师......

@IBAction func push(sender: UITapGestureRecognizer) {

    let pushBehavior = UIPushBehavior(items: [aView], mode: .Instantaneous)
    pushBehavior.magnitude = 0.5
    pushBehavior.action = { [unowned pushBehavior] in
        pushBehavior.dynamicAnimator!.removeBehavior(pushBehavior)
    }
    animator.addBehavior(pushBehavior)

}

我还将动画师的referenceView设置为应该发生动作的gameView ......

private lazy var animator : UIDynamicAnimator = {

   let lazilyCreatedDynamicAnimator = UIDynamicAnimator(referenceView:self.gameView)
   return lazilyCreatedDynamicAnimator

}()

我希望你能帮助我找出解决我的小问题的方法......

0 个答案:

没有答案