Login required for access
In order to watch this lesson, you'll need to login to the website.
Blur With UIViewPropertyAnimator
Swift Stretchy Header CollectionView
Let's go ahead and take our stretchy header effect and kick it up a notch by introducing a visual blur as we drag up and down. This is done very simply by adding a UIViewPropertyAnimator in our HeaderView class. In addition to this animator, we'll modify the fractionComplete property that allows us to control the amount of blur that is applied. Enjoy.
### iOS 13 Update for Blur **HeaderView.swift** ```swift fileprivate func setupVisualEffectBlur() { addSubview(visualEffectView) visualEffectView.fillSuperview() // iOS 13 UPDATE: You now have to set .effect to nil, otherwise blur instantly begins at full intensity animator = UIViewPropertyAnimator(duration: 1.0, curve: .linear, animations: { self.visualEffectView.effect = nil }) // Reverse animator so that we can use fractionComplete of 0 as our "starting point". You don't have to do this, but it makes for easier calculations in your StretchyHeaderController.scrollViewDidScroll animator.isReversed = true animator.fractionComplete = 0 } ``` Download the project to see the full changes.

Comments (3)
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
HELP & SUPPORT