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

BlurEffect can't change Alpha #6

Closed
MichMich opened this issue Sep 16, 2014 · 9 comments
Closed

BlurEffect can't change Alpha #6

MichMich opened this issue Sep 16, 2014 · 9 comments

Comments

@MichMich
Copy link

As discussed in this pull request: #5

I'm still receiving an warning:

2014-09-16 14:29:47.912 PKHUD Demo[50313:10503170] <PKHUD.FrameView 0x7fa053e609d0> is being asked to animate its opacity. This will cause the effect to appear broken until opacity returns to 1.

It appears PKHUD is trying to animate the Alpha of the FrameView, while it's a subclass of UIVisualEffectView. The documentation of the VisualEffectView states the following:

Setting the Correct Alpha Value
When using the UIVisualEffectView class, avoid alpha values that are less than 1.
Creating views that are partially transparent causes the system to combine the view 
and all the associated subviews during an offscreen render pass. UIVisualEffectView 
objects need to be combined as part of the content they are layered on top of in order
to look correct. Setting the alpha to less than 1 on the visual effect view or any of its 
superviews causes many effects to look incorrect or not show up at all.

So to solve this notification, the alpha fading must be done differently.

Any suggestions?

Cheers,
//Michael

@esmondmissen
Copy link

I'm currently doing the same thing as you. Looks fine to me but yeah, it's annoying they don't want you to do it like that. Off the top of my head you could do a screen capture to a UIImage add a blur filter and change it's opacity maybe?

@pkluz
Copy link
Owner

pkluz commented Jan 10, 2015

I really don't want to do what @esmondmissen suggests. It's a lot of overhead and additional processing for something that currently seems to work flawlessly with barely any additional work (I have yet to receive a complaint about visual glitches due to animating the opacity of visual effect views - possibly ontop of GLKit views? Not tested).

As a matter of fact (despite producing a warning) I find the current solution to be 1. the most obvious 2. elegant, 3. concise and 4. maintainable.

@carlos4242
Copy link

I agree with you. I was Googling for this error message to find a fix. Before iOS 8 I wrote a class to implement blur using GLKit and core image rendering on the GPU. It's not perfect and I'd prefer to use the Apple supplied view as their engineers have access to parts of the system that I don't. But it's fast and flexible. You're welcome to use it if you want. https://github.com/carlos4242/FrostedGlass

@sebromero
Copy link

Although I really hate warnings like this one, I agree with @pkluz. I am pretty sure there is a (probably undocumented) way to do it without causing this warning. If one of you guys will attend WWDC, go ahead and ask one of the UIKit guys.

@emadd
Copy link

emadd commented May 8, 2015

It's "hacky" but maybe you can simply take advantage of UIToolbar's effect. Works for me in modal views I want "frosted".

view.backgroundColor = UIColor.clearColor()
let bgToolbar = UIToolbar(frame: view.frame)
view.insertSubview(bgToolbar, atIndex: 0)

@rocketes
Copy link

Does this warning make any problems when pushing the app to the App Store?

@pkluz
Copy link
Owner

pkluz commented Feb 25, 2016

Not at all.

On 25 Feb 2016, at 11:01 AM, Dieter Schäfer notifications@github.com wrote:

Does this warning make any problems when pushing the app to the App Store?


Reply to this email directly or view it on GitHub.

@Hengyu
Copy link

Hengyu commented Apr 28, 2016

Hi, pkluz

I have been using your framework for a while, it's great and easy to use. However, I encountered the same problem as this. Then I found a workaround, and no warning log appears :)
The idea is make the FrameView as a subclass of UIView and set the visualEffectView as its internal subview.
I've attached the file FrameView.swift, please have a look.
FrameView.txt

Cheers,
Hengyu

@pkluz
Copy link
Owner

pkluz commented Apr 28, 2016

This is a pretty good idea @Hengyu ! Fantastic! Will look at it!

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

8 participants