Animating a UIPopoverPresentationController view's center position

124 Views Asked by At

Overall my goal is to present a custom UIViewController over the screen as a sort of "widget". The view would animate by starting out with its center at a starting point in my root view and then move the view until it is positioned at the center of the root view. This presented view should be able to animate its own height and width.

Currently, I am using a ViewController along with a UIPopoverPresentationController that has a custom empty and transparent popoverBackgroundViewClass . I am using a popover controller so that I can use my viewController's preferredContentSize as a way to allow the "popped" in view to easily change its own height and width. (If a popover presentation controller isn't right for handling something like this, I'd love to know)

The issue I have run into with using a UIPopoverPresentationController is that I can set its position with self.popoverPresentationController.sourceRect = CGRectMake(point.x, point.y, 0,0); where point refers to a CGPoint that determines the center of the popover view. If I could somehow animate this popover view's center from one point to another that would solve all of my problems, but I can't figure out anything that would make this work.

I can't tell if it's my inexperience with this sort of thing but every approach I have tried just feels hacky, so any help on doing this the right way is very much so appreciated.

0

There are 0 best solutions below