How to present popover with animations?
Asked Answered
U

2

7

Currently, I'm using presentPopoverFromRect:inView:permittedArrowDirections:animated: to present my popover. But I'm looking for more fanciful animations (eg. the popover expanding from a particular point) to present the popover.

I've tried searching with keywords ios present popover animation but can't find any useful results. Not sure if I'm using the wrong keywords or it is impossible to present popovers with animations.

Unassailable answered 11/6, 2013 at 2:52 Comment(0)
L
3

When using a UIPopover, there is currently no easy way to present it with a different animation than the one that iOS provides. It would definitely be possible to do a custom animation to present a view, but it would be a very significant amount of extra work as you would have to do everything yourself. Two things you could look at if you really, really need to:

  1. UIView animation. Links: Ray Wenderlich tutorial, Apple documentation (search the page for "animation").
  2. Core Animation custom transitions.
Late answered 11/6, 2013 at 3:28 Comment(1)
Thanks for the answer! I figured a way to create a simple 'animation' by using setPopoverContentSize. By presenting the popover with smaller dimensions, and use setPopoverContentSize to expand it. Sort of an 'animation'. I guess that is the most straightforward way for now.Unassailable
S
2

As of iOS 7.0 it is possible to present any view controller so that it does not completely obscure the previous view controller, making it possible to create "fake" popovers. Using the UIViewControllerTransitioningDelegate protocol you can then create any animation you would like.

Here is a good example of how to create a fake popover with a custom animation.

Starknaked answered 28/11, 2013 at 21:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.