uakihir0 / UIPiPView

This library is a UIView that is capable of Picture-in-Picture (PiP) in iOS.
MIT License
216 stars 32 forks source link

Show animation / Hide view #7

Closed rozmarica closed 2 years ago

rozmarica commented 2 years ago

Hi! I need to show an animation when pipView starts (imageView should shrink smoothly) - can this be done with this library? When I try to make an animation, pipView immediately shows its final result, without animation.

Second question. Is it possible to override the behavior of the top right button (which is used to exit pip mode)? For example, just close pipView, as when clicking on a cross.

uakihir0 commented 2 years ago

Hi!

It is a specification that animations using functions such as UIView.animate are not reflected in UIPiPView. This is because when rendering UIView.layer to CGContext, it does not reflect the animation in progress.

As a workaround, you can use the Timer class or other methods to reproduce the animation. For example, if you make the UIView a little smaller every 0.1 second, the animation will be reflected in the UIPiPView.

The developer has no control over the buttons when they are in PiP. The callback after the button is pressed is overridden on the UIPiPView class, so it is possible to override it further and have the process changed. Please refer to the documentation for the details of each delegate function.

Thanks.

https://github.com/uakihir0/UIPiPView/blob/main/UIPiPView/Classes/UIPiPView.swift#L195 https://developer.apple.com/documentation/avkit/avpictureinpicturecontrollerdelegate

rozmarica commented 2 years ago

Thanks!