Skip to content

Instantly share code, notes, and snippets.

@msadoon
Created October 30, 2016 21:20
Show Gist options
  • Save msadoon/84d37221001170f6416119cadc09d4b2 to your computer and use it in GitHub Desktop.
Save msadoon/84d37221001170f6416119cadc09d4b2 to your computer and use it in GitHub Desktop.
UIView Frame Animation
let newFrame = CGRect(x:self.frame.origin.x, y: self.frame.origin.y, width:self.frame.size.width, height:((self.frame.size.height*2) + heightDiff));
let scale:CABasicAnimation = CABasicAnimation.init(keyPath:"path");
print("newFrame: \(newFrame)");
scale.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut);
scale.fromValue = self.frame;
scale.toValue = newFrame;
scale.duration = 1.0;
scale.isRemovedOnCompletion = false;
scale.fillMode = kCAFillModeForwards;
scale.delegate = self;
self.maskLayer.add(scale, forKey: "path");
self.frame = CGRect(x:self.frame.origin.x, y: self.frame.origin.y, width:self.frame.size.width, height:((self.frame.size.height*2) + heightDiff));
print("frame after animation: \(self.frame)");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment