I am able to successfully change the frame of a popover I present by simply setting preferredContentSize
. I would now like to animate the change in the content size but I haven't been successful. It just instantly updates, in fact the delay I have set isn't even respected. How could one animate the change in content size?
//In viewDidAppear:
UIView.animateWithDuration(5, delay: 3, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.25, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in
self.preferredContentSize = CGSizeMake(320, 400)
}, completion: nil)
I was able to reproduce your problem, then figured out a way to make it work. The animation delay just isn't working here, so set that to 0 and do a different type of delay before doing the animation. I use a function I found here on SO:
Just put that at the top of any swift file, outside of the class definition.
Then change your code to look like this: