FXBlurView icon indicating copy to clipboard operation
FXBlurView copied to clipboard

blurView messes with sibling imageView (transparent png with `UIInterpolatingMotionEffect`)

Open alfiehanssen opened this issue 10 years ago • 7 comments

I'm adding a blurView as a child of a view that has a UIImageView child that contains a transparent png with a UIInterpolatingMotionEffect applied to it.

i.e. in my UIViewController subclass I'm adding the UIImageView instance and then a blurView instance.

The transparent png is a fullscreen image with a little white pattern applied to it. The whole png has transparency, so even the parts occupied by the white pattern shapes are only about 0.4 alpha.

When I add the blurView the white areas of the image seem to become inverted, now dark gray. This only happens when I add the blurView to the view hierarchy.

See screenshot below (blurView occupies only the top 54 pixels of the screen. It properly blurs the white flecked pattern behind it. But the pattern over the rest of the screen space is inverted (white is now dark gray).

Any ideas how to prevent this from happening?

screenshot 2013 10 19 00 18 34

alfiehanssen avatar Oct 19 '13 04:10 alfiehanssen

This is an issue of CGDataproviderCopyData http://openradar.appspot.com/15195959

toco avatar Oct 19 '13 20:10 toco

Wow, that is interesting (and deeply disturbing). Is there a workaround?

nicklockwood avatar Oct 19 '13 22:10 nicklockwood

Btw, @alfiehanssen, if you're just targeting iOS7, why not use a regular UIToolbar instead of FXBlurView?

nicklockwood avatar Oct 19 '13 22:10 nicklockwood

@nicklockwood, I did try that first and got some pretty odd results (grayscale tint, among other things) but may explore further. The big issue with using the Toolbar approach is that it appears tough (impossible?) to get a non-tinted blur (I want something that blurs what's behind it without tinting it opaque white or similar, see attached image). Regardless, your demo is awesome.

13c14cba-3857-11e3-9bc6-bb4c61b354f5

alfiehanssen avatar Oct 20 '13 00:10 alfiehanssen

btw @toco thanks for the quick and super direct/helpful radar link, nice to know the extent of what's happening here.

alfiehanssen avatar Oct 20 '13 00:10 alfiehanssen

@nicklockwood I found this bug when using your UIImage blur category. My workaround is to "deep copy" the image before blurring it, I don't know how it can be applied to FXBlurView but there should be a possibility.

- (instancetype)ssi_deepCopy {
    UIImage *imageToCopy = self;
    UIGraphicsBeginImageContext(imageToCopy.size);
    [imageToCopy drawInRect:CGRectMake(0, 0, imageToCopy.size.width, imageToCopy.size.height)];
    UIImage *copiedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return copiedImage;
}

toco avatar Oct 20 '13 08:10 toco

Regarding the UIToolbar trick: I think of it as an hack and one should be really careful when modifying the view hierarchy of framework components. Then again it disables blur on older devices and also respects the accessibility settings for free. So the performance impact of live-blurring does not happen on old devices, which is a good thing and system-wide consistent. Does anybody know the (private) API which decides whether or not blurring is enabled?

Apple told at the WWDC that they trick a lot with 'live' blurring for performance. Sadly I don't remember the exact example and session, but when showing a sheet or something, they blur the whole background first and just show the visible part. When the view moves there is no need for new blurring, they just move pre-blurred view.

toco avatar Oct 20 '13 08:10 toco