facebookanimationswiftfacebook-pop

Swift NSValue.valueWithCGRect


I'm trying to animate the bounds of a UIButton using Facebook pop POPSpringAnimation, but I can't find what I should use in swift in replace of NSValue.valueWithCGRect

This is what I'm trying to do:

@IBAction func buttonTapped(sender : UIButton) {

    var springAnimation = POPSpringAnimation()
    springAnimation.property = POPAnimatableProperty.propertyWithName(kPOPLayerBounds) as POPAnimatableProperty
    springAnimation.springBounciness = 12.0
    springAnimation.springSpeed = 10.0

    springAnimation.toValue = NSValue.valueWithCGRect(newBounds)

    shutterButton.pop_addAnimation(springAnimation, forKey: "size")

}

Solution

  • This will compile:

    let rect = CGRect(x: 0,y: 0,width: 1,height: 1)
    let val = NSValue(CGRect: rect)
    

    This is "initializer syntax"