Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Facebook PoP ios框架水平翻转UIView?_Ios_Objective C_Swift_Facebook - Fatal编程技术网

如何使用Facebook PoP ios框架水平翻转UIView?

如何使用Facebook PoP ios框架水平翻转UIView?,ios,objective-c,swift,facebook,Ios,Objective C,Swift,Facebook,我正在使用用于iOS的facebook Pop框架。 如何使视图水平翻转(在其Y轴上) 这是我的密码: func buttonClicked(sender: UIButton) { aBoolValue = !aBoolValue sender.userInteractionEnabled = false let layer = sender.layer // First let's remove any existing animations laye

我正在使用用于iOS的facebook Pop框架。 如何使视图水平翻转(在其Y轴上)

这是我的密码:

func buttonClicked(sender: UIButton) {
    aBoolValue = !aBoolValue
    sender.userInteractionEnabled = false
    let layer = sender.layer

    // First let's remove any existing animations
    layer.pop_removeAllAnimations()
    layer.removeAllAnimations()
    let rotation: POPSpringAnimation = POPSpringAnimation(propertyNamed:kPOPLayerRotationY)

    if aBoolValue == true {
        rotation.toValue = M_PI
        sender.setTitle("G", forState: UIControlState.Normal)
    } else {
        rotation.toValue = 0
        sender.setTitle("P", forState: UIControlState.Normal)
    }

    rotation.completionBlock = {(anim: POPAnimation! , finished: Bool) -> Void in
        layer.pop_removeAllAnimations()
        sender.userInteractionEnabled = true
    }

    layer.pop_addAnimation(rotation, forKey: "rotation")

这样做的结果是,它按预期翻转,但在大约5-6次翻转后,动画开始随机翻转,而不是正常翻转。如何以正确的方式水平翻转视图?

这是pop库中的一个错误。看

人们可以使用
ui视图创建一些类似的动画。animateWithDuration:
方法

比如说

private func get3DTransformation(angle: Double) -> CATransform3D {

    var transform = CATransform3DIdentity
    transform.m34 = -1.0 / 500.0
    transform = CATransform3DRotate(transform, CGFloat(angle * M_PI / 180.0), 0, 1, 0.0)

    return transform
}

private func flipAnimation(view: UIView, completion: (() -> Void) = {}) {

    let angle = 180.0
    view.layer.transform = get3DTransformation(angle)

    UIView.animateWithDuration(1, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: .TransitionNone, animations: { () -> Void in
        view.layer.transform = CATransform3DIdentity
        }) { (finished) -> Void in
            completion()
    }
}


为什么没有理由就投了反对票?
func buttonClicked(sender: UIButton) {

    aBoolValue = !aBoolValue
    if aBoolValue == true {
        sender.setTitle("G", forState: UIControlState.Normal)
    } else {
        sender.setTitle("P", forState: UIControlState.Normal)
    }

    flipAnimation(sender)
}