1

Working on a departed coworkers project. I need to implement this objective-C code for this Facebook Pop animation into Swift. I will just paste it in its entirety since only a few lines long. I've looked at a few tutorials but being new at Pop and Swift has made this tricky. How would I write this in Swift?

- (void)scaleDownView:(UIView *)view
{
  POPSpringAnimation *scaleAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
  scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(0.1, 0.1)];
  scaleAnimation.springBounciness = 6.f;
  [view.layer pop_addAnimation:scaleAnimation forKey:@"scaleAnimation"];
}
timpone
  • 19,235
  • 36
  • 121
  • 211

1 Answers1

0

I'm assuming you've added a bridging header to the project in question. Imported #import <pop/POP.h> in the bridging header. You'll have to import pop at the top of any Swift file you'd like to use the below method.

    func scaleDownView(view: UIView) {
        let scaleAnimation = POPSpringAnimation(propertyNamed:kPOPLayerScaleXY)
        scaleAnimation.toValue = NSValue(CGSize: CGSize(width: 0.1, height: 0.1))
        scaleAnimation.springBounciness = 6.0
        view.layer.pop_addAnimation(scaleAnimation, forKey: "scaleAnimation")
    }
Xeaza
  • 1,410
  • 1
  • 17
  • 21