Skip to content

Instantly share code, notes, and snippets.

@Clancey
Last active December 24, 2015 14:59
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Clancey/6816609 to your computer and use it in GitHub Desktop.
Save Clancey/6816609 to your computer and use it in GitHub Desktop.
A brightly colored iOS 7 UIBlurView
using System;
using MonoTouch.UIKit;
using MonoTouch.CoreAnimation;
public class BrightlyBlurredUIView: UIView
{
CALayer blurLayer,accentLayer;
UIView accentView;
UIToolbar toolbar;
public BrightlyBlurredUIView()
{
toolbar = new UIToolbar {
Opaque = true,
};
this.Layer.AddSublayer(blurLayer = toolbar.Layer);
accentView = new UIView {
BackgroundColor = this.TintColor,
Alpha = .7f,
Opaque = false
};
blurLayer.InsertSublayer(accentLayer = accentView.Layer,1);
this.Layer.MasksToBounds = true;
this.BackgroundColor = UIColor.Clear;
}
public override void LayoutSubviews ()
{
base.LayoutSubviews ();
var bounds = Bounds;
accentLayer.Frame = blurLayer.Frame = bounds;
}
public float AccentColorIntensity
{
get{ return accentView.Alpha; }
set{ accentView.Alpha = value; }
}
public override UIColor TintColor {
get {
return base.TintColor;
}
set {
base.TintColor = toolbar.BarTintColor = accentView.BackgroundColor = value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment