Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIVisualEffectView transition #26

Closed
felix-dumit opened this issue Jan 8, 2017 · 11 comments
Closed

UIVisualEffectView transition #26

felix-dumit opened this issue Jan 8, 2017 · 11 comments
Milestone

Comments

@felix-dumit
Copy link

felix-dumit commented Jan 8, 2017

I added a UIVisualEffectView to the MusicPlayer example to simulate this issue.
It breaks during the transition and also after the transition is complete it's still not the way it should be.

Hero off

Hero off

Hero on

Hero on

Console outputs this warning:

[Warning] <UIVisualEffectView 0x7fa50e80b830> is being asked to animate its opacity. This will cause the effect to appear broken until opacity returns to 1.

Code used is available here: https://github.com/felix-dumit/Hero/tree/visual-effect-snapshot

Any ideas? Maybe take a snapshot of the window at the effectView (final) bounds?

I played around with this idea here: 7d9f0f1

Still needs some work but here is an initial result:
Temp anim
It still breaks once the animation is complete, though.

This is probably an unrelated question, but in the above scenario, how could I make it so the effectView frame doesn't animate (i.e it already starts with the the final frame)?

@fruitcoder
Copy link
Contributor

I haven't looked at the exact code that peforms the animations, but is it possible to check for the views that are animated (traversing the view hierarchy)? Then every VisualEffectView's effect would be set to nil and reset in an animation block. That way it could be animated

@lkzhao lkzhao added this to the v1.0 milestone Feb 12, 2017
@lkzhao
Copy link
Collaborator

lkzhao commented Feb 12, 2017

With the new .overFullScreen support. This should be possible. We just have to figure out how to animation UIVisualEffectView, since it doesn't support opacity animation.

@fruitcoder
Copy link
Contributor

As I said UIVisualEffectView can animate its blur by setting the effect from nil to a blur effect in an animation block so you might have to make a special case if a view is a UIVisualEffectView and the opacity is to be animated

@lkzhao
Copy link
Collaborator

lkzhao commented Feb 13, 2017

Yes, but that doesn't allow interactive scrubbing or reversing the animation.

@fruitcoder
Copy link
Contributor

For that you have to set the blur with a UIViewPropertyAnimator and then scrub by setting it's progress

@fruitcoder
Copy link
Contributor

But that's iOS 10+

@lkzhao
Copy link
Collaborator

lkzhao commented Feb 15, 2017

I tried implementing the UIViewPropertyAnimator. I modify to menu example to have a blur background.

http://lkzhao.com/video/?path=%5Cpublic%5Cposts%5Chero%5Cmenu.mov

It doesn't works when it is interactive though. Whenever, I set the .fractionComplete, the blur effect immediately jumps to the end.

@felix-dumit
Copy link
Author

Maybe if it's interactive you have to take a snapshot of the view and animate its alpha similar to the way I tried to do it?

@felix-dumit
Copy link
Author

@lkzhao Actually the way you tried should work, check out this example project: https://github.com/fichek/AnimateBlurRadius/

@felix-dumit
Copy link
Author

I think the problem is here: https://github.com/lkzhao/Hero/blob/master/Sources/HeroViewPropertyViewContext.swift#L59
Since it already starts the animation immediately, if it is interactive it shouldn't do that and only rely on the fractionComplete.

@jegnux
Copy link

jegnux commented Feb 17, 2017

If you set the UIVisualEffectView as your's UIViewController.view in loadView(), then the transition is automatically handled by UIKit. Maybe it'll solve your issue.

@lkzhao lkzhao closed this as completed Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants