Skip to content

Instantly share code, notes, and snippets.

@svrooij
Last active August 29, 2015 14:02
Show Gist options
  • Save svrooij/21a9430cfdce879155ba to your computer and use it in GitHub Desktop.
Save svrooij/21a9430cfdce879155ba to your computer and use it in GitHub Desktop.
Use tinted images in MonoTouchDialog ImageStringElement
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
namespace FhictPhoto
{
public partial class TintedImageDialog : DialogViewController
{
public TintedImageDialog () : base (UITableViewStyle.Grouped, null)
{
Root = new RootElement ("TintedImageDialog") {
new Section ("First Section") {
new TintImageStringElement("Title",UIImage.FromBundle("Images/sample.png")){TintColor = UIColor.Red}
},
};
}
}
}
using System;
using MonoTouch.UIKit;
namespace MonoTouch.Dialog
{
public class TintImageStringElement : ImageStringElement
{
public UIColor TintColor { get; set; }
public TintImageStringElement (string caption, UIImage image):base(caption,image.ImageWithRenderingMode (UIImageRenderingMode.AlwaysTemplate))
{
TintColor = UIColor.FromRGB (102, 51, 102);
}
public override UITableViewCell GetCell (UITableView tv)
{
var cell = base.GetCell (tv);
cell.ImageView.TintColor = TintColor;
return cell;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment