Skip to content

Instantly share code, notes, and snippets.

@vparihar01
Created July 6, 2015 11:15
Show Gist options
  • Save vparihar01/dfb05802e567970bd7b7 to your computer and use it in GitHub Desktop.
Save vparihar01/dfb05802e567970bd7b7 to your computer and use it in GitHub Desktop.
swift Blur, Vibrant and Vibrancy
// 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment