var imgsizewhite = new SizeF((float)0.5,(float)0.5);
var imageSizeRectWhite = new RectangleF(0, 0,(float)0.5,(float)0.5);
UIGraphics.BeginImageContextWithOptions(imgsizewhite, false, 0);
var contextwhite = UIGraphics.GetCurrentContext();
UIColor imgwhitecolor = UIColor.FromRGB (255, 255, 255);
contextwhite.SetFillColor(imgwhitecolor.CGColor);
contextwhite.FillRect(imageSizeRectWhite);
var imgwhite = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
var imgsizegray= new SizeF((float)0.5,(float)0.5);
var imageSizeRectgray = new RectangleF(0, 0,(float)0.5,(float)0.5);
UIGraphics.BeginImageContextWithOptions(imgsizegray, false, 0);
var contextgray = UIGraphics.GetCurrentContext();
UIColor imggraycolor = UIColor.FromRGB (245,245,245);
contextgray.SetFillColor(imggraycolor.CGColor);
contextgray.FillRect(imageSizeRectgray);
var imggray = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
btnFirst.SetBackgroundImage (imgwhite, UIControlState.Normal);
btnFirst.SetBackgroundImage (imggray, UIControlState.Highlighted);
btnSecond.SetBackgroundImage (imgwhite, UIControlState.Normal);
btnSecond.SetBackgroundImage (imggray, UIControlState.Highlighted);
注意:按钮的Type一定要设置成Custom