Building the UIImageEffects class

Our final part to the image tinting on iOS is implementing the class that will return a tinted image from a template image and color. Create a new folder in the iOS project called Helpers, add a new file called UIImageEffects.cs, and implement the following:

public static class UIImageEffects { public static UIImage GetColoredImage(UIImage image, UIColor color) { UIImage coloredImage = null; UIGraphics.BeginImageContext(image.Size); using (CGContext context = UIGraphics.GetCurrentContext()) { context.TranslateCTM(0, image.Size.Height); context.ScaleCTM(1.0f, -1.0f); var rect = new CGRect(0, 0, image.Size.Width, image.Size.Height); // draw image, (to get transparancy mask) context.SetBlendMode(CGBlendMode.Normal); ...

Get Xamarin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.