Skip to content

Instantly share code, notes, and snippets.

@vparihar01
Created July 6, 2015 11:15

Revisions

  1. vparihar01 created this gist Jul 6, 2015.
    23 changes: 23 additions & 0 deletions addEffect.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    // Blur Effect
    var blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
    var blurEffectView = UIVisualEffectView(effect: blurEffect)
    blurEffectView.frame = view.bounds
    view.addSubview(blurEffectView)

    // Vibrancy Effect
    var vibrancyEffect = UIVibrancyEffect(forBlurEffect: blurEffect)
    var vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect)
    vibrancyEffectView.frame = view.bounds

    // Label for vibrant text
    var vibrantLabel = UILabel()
    vibrantLabel.text = "Vibrant"
    vibrantLabel.font = UIFont.systemFontOfSize(72.0)
    vibrantLabel.sizeToFit()
    vibrantLabel.center = view.center

    // Add label to the vibrancy view
    vibrancyEffectView.contentView.addSubview(vibrantLabel)

    // Add the vibrancy view to the blur view
    blurEffectView.contentView.addSubview(vibrancyEffectView)