Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Styrmist/db3f880bd6cced6c8c175084cc5924a1 to your computer and use it in GitHub Desktop.

Select an option

Save Styrmist/db3f880bd6cced6c8c175084cc5924a1 to your computer and use it in GitHub Desktop.

Revisions

  1. @darrarski darrarski revised this gist Nov 24, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CustomIntensityVisualEffectView.swift
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ class CustomIntensityVisualEffectView: UIVisualEffectView {
    }

    required init?(coder aDecoder: NSCoder) {
    return nil
    fatalError()
    }

    // MARK: Private
  2. @darrarski darrarski created this gist Nov 24, 2017.
    24 changes: 24 additions & 0 deletions CustomIntensityVisualEffectView.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    import UIKit

    class CustomIntensityVisualEffectView: UIVisualEffectView {

    /// Create visual effect view with given effect and its intensity
    ///
    /// - Parameters:
    /// - effect: visual effect, eg UIBlurEffect(style: .dark)
    /// - intensity: custom intensity from 0.0 (no effect) to 1.0 (full effect) using linear scale
    init(effect: UIVisualEffect, intensity: CGFloat) {
    super.init(effect: nil)
    animator = UIViewPropertyAnimator(duration: 1, curve: .linear) { [unowned self] in self.effect = effect }
    animator.fractionComplete = intensity
    }

    required init?(coder aDecoder: NSCoder) {
    return nil
    }

    // MARK: Private

    private var animator: UIViewPropertyAnimator!

    }