Skip to content

Instantly share code, notes, and snippets.

@mikebluestein
Created July 8, 2014 22:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mikebluestein/3443c3d86c01566b51fb to your computer and use it in GitHub Desktop.
Save mikebluestein/3443c3d86c01566b51fb to your computer and use it in GitHub Desktop.
iOS 8 Visual Effects using Xamarin
using System;
using System.Drawing;
using MonoTouch.UIKit;
namespace ViewEffectsDemo
{
public class EffectsController : UIViewController
{
UIImageView imageView;
UIScrollView scrollView;
UILabel label;
public override void ViewDidLoad ()
{
imageView = new UIImageView ();
using (var image = UIImage.FromFile ("monkey.jpg")) {
imageView.Image = image;
imageView.Frame = new RectangleF (0, 0, image.Size.Width, image.Size.Height);
}
scrollView = new UIScrollView (View.Frame) {
ContentSize = imageView.Image.Size
};
scrollView.Add (imageView);
View.Add (scrollView);
// blur view
var blur = UIBlurEffect.FromStyle (UIBlurEffectStyle.Light);
var blurView = new UIVisualEffectView (blur) {
Frame = new RectangleF (0, 0, imageView.Frame.Width, 400)
};
View.Add (blurView);
// vibrancy view
var frame = new Rectangle (10, 10, 100, 50);
var vibrancy = UIVibrancyEffect.FromBlurEffect (blur);
var vibrancyView = new UIVisualEffectView (vibrancy) {
Frame = frame
};
label = new UILabel {
Text = "Hello iOS 8!",
Frame = vibrancyView.Bounds
};
vibrancyView.ContentView.Add (label);
blurView.ContentView.Add (vibrancyView);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment