Skip to content

lipka/MonoTouch.UIImageEffects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MonoTouch.UIImageEffects

A native port of the UIImage categories by Apple from WWDC 2013.

Usage

UIImage image = UIImage.FromFile ("cheetah.png")
image = image.ApplyDarkEffect ();

The infamous iOS7 blur

Getting the iOS7 style blur is a bit more tricky but can be achieved with the following code.

// Helper method to create an image snapshot of a view
UIImage SnapshotImageWithScale (UIView view, float scale)
{
    UIGraphics.BeginImageContextWithOptions (view.Bounds.Size, false, scale);
    view.DrawViewHierarchy (view.Bounds, true);

    UIImage image = UIGraphics.GetImageFromCurrentImageContext ();
    UIGraphics.EndImageContext ();

    return image;
}

...

// Create snapshot of the parent view (this can be the superview or anything else)
UIImage snapshot = SnapshotImageWithScale (parentView, UIScreen.MainScreen.Scale);

// Blur the snapshot with the specified radius and tint color
snapshot = snapshot.ApplyBlur (6.0f, UIColor.FromWhiteAlpha (0.0f, 0.6f), 0.8f, null);

// Create an UIImageView to display the blurred snapshot
UIImageView snapshotView = new UIImageView {
    Frame = new RectangleF (0, 0, View.Bounds.Width, View.Bounds.Height),
    Image = snapshot,
};
View.AddSubview (snapshotView);

Installation

Either drop in src/UIImageExtensions.cs to your project or build a standalone library and reference it.

Requirements

MonoTouch.UIImageEffects is tested on iOS7, but may be compatible with lower versions.

Contact

Lukas Lipka

License

MonoTouch.UIImageEffects is available under the MIT license. See the LICENSE file for more info.

About

Native port of Apple's WWDC UIImage+Effects categories for MonoTouch.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages