UIScrollView Blur Effect - ios

A am using the brilliant StackBlur class with in my project which works fine however I am trying to create a similar effect to the Yahoo Weather App in which the image blurs according to the scroll value. I have managed to achieve it using the scrollViewDidScroll method however the effect is slow and laggy.
What is the best way yo resolve this? Storing the image to the Cache is the only thing I can think of.
Thanks
UPDATE
I simply created two UIImageViews one with the blur and then set the alpha to zero and increased it with the content offset off the scrollview.

You don't need to blur every time when scrollViewDidScroll called. Instead, you need a blurred imageView with the final blur effect and none blurred imageView placed below the blurred one. Change view.alpha of blurred imageView from 0.0 to 1.0 will get this effect without extra cost.

Try DKLiveBlur to show live effect of yahoo blur.

Related

tvOS: UIImageView with rounded corners without losing the focus animation

I am displaying a collection view with an UIImageView for each cell. My images are being animated on cell focus (the standard animation where the image pops out).
However, I also need to round the corners of the image by setting the imageView.layer.cornerRadius. The problem is that once I set maskToBounds = true my imageView stops popping out on focus and without that I cannot achieve the rounded corners.
I’ve checked in other SO questions and some people suggested post-process the image in runtime using Core Graphics but this is too much processing for my collectionView.
Is there any alternative to achieve this? (The iTunes movie app does it, so I suppose there must be)
Setting maskToBounds crops the image when focused because the cell extends out of its bounds to get the parallax animation.
The issue is that to generate rounded corners with that method you need to set maskToBounds to true.
So... your final goal could be achieved using a different method to generate rounded corners, via CoreGraphics for example, that does not require setting maskToBounds.
Or, what I am personally doing, to use this open source library, which allows adding parallax effect to any UIView https://github.com/PGSSoft/ParallaxView

Swift: make UIScrollView have a "going out of focus" effect

I'd like to know which library/object/function I should refer to to be able to make my scroll views have that nice out of focus effect. For example make the image coming on screen look smaller as it goes away and blur it at the same time.
My scroll view contains ImageViews that take up the entire bounds of the scroll view.
Blur
For iOS 8+, you can use UIVisualEffectView to achieve this effect. This is a native API that has been fine tuned for performance and great battery life, and it's easy to implement. Alternatively you can check out GPUImageGaussianBlurFilter as described here.
Scale
Check out transform property of the UIView. Using CGAffineTransformMakeScale you can change the scale. Read this very informative blog post about transformations.

UIVisualEffectsView animation bug

I'm trying to animate a UIVisualEffectsView with a blur effect on top of a UIImageView. Animating the effects view 'in' seems to work, however when animating it 'out' on the first animation frame the effect vanishes to what looks like a 0.5 alpha view.
Is this a bug in iOS8 or am I doing it wrong?
You can play with the example project at https://github.com/mickeyl/iOS-Bug-Example-Projects/tree/master/Animating-UIVisualEffectsView
Here is a preview of what I'm seeing:
Update: Obviously the problem is the height parameter in the new rect. Keeping it works around it. If you then add the effect as subview to the image and clipToBounds, I can get the intended effect. Still I view this as a bug.
This is the response from Apple Developer Relations:
This issue behaves as intended based on the following:
When animating the height 0 -> 300, the presentation layer in the
render server knows its full size so the render server can properly
sample for blur. When returning back to zero height, the presentation
layer now has a height of zero, to which the render server has no way
to sample correctly. So the effect drops but the remaining layers
still animate properly.
Your solution is the correct one. The render server simply cannot
accommodate blur in this scenario.
Please update your bug report to let us know if this is still an issue
for you.

Fade UIImageView as it approaches the edges of a UIScrollView

I have a UIScrollView over an image at the bottom of my app that acts as a dock with icons that can be scrolled through horizontally. Instead of the harsh edges of the UIScrollView, I would like the icons to fade out for a more aesthetically pleasing look. Being new to iOS development, I don't know if either of these would be valid options:
Create a faded image to use as an overlay on the scrollview so the
icons only appear through the visible portion.
Actually change the
alpha of the images based on their distance from the center (or from
each edge).
I suspect the first idea would be the most simple, but I'd like to throw this out there for any other ideas.
Note: I did see this tutorial, however that technique assumes that the background is a solid color. If I were to do it programatically, I would probably need to fade the individual images.
You can definitely implement something along the lines of #2. It'd be something similar to what the tutorial describes. The alpha transition however won't be as smooth as using the gradient layer mentioned in the tutorial or using an image since the entire icon would have the same alpha. How much discernible the difference is depends on the size of your icons. Smaller icons, very few will be able to tell the difference. Larger icons the difference would be quite clear.
You'd have to implement the
(void)scrollViewDidScroll:(UIScrollView *)scrollView
method in your scroll view's delegate class. This method will get called every time the scroll view changes the location of its content. In this method you can call its subviews and adjust their alphas as required. To optimize it a bit instead of calling the alpha adjustments on all the elements you can just update the subviews which are still partially/completely visible.
EDIT: to figure out which views to adjust you'll use the contentOffset property of the scrollView that gets passed as a parameter in the above method.

How to make UIImageView scroll like movie credits?

I want to make Credits in my application, so I make that as an image and I am using UIImageView. I want to make that image scroll up from bottom unseen until all image finish and repeat again infinitely.
I can do that with cocos2d but now I am not using cocos2d and only use UIImageView.
Please share some code...Thanks in advance.
Stick the long image into a UIScrollView and animate its contentOffset. Repeat infinitely. If your image is very large, it might be a good idea to split it into several small ones and insert them consecutively.

Resources