I am newbie to Monotouch and have added the following code to my SingleViewApplication. And you can see my controller code below, where I am trying to change the background
I am also face this problem but i solve this issue hope this code is help you
public static class SwapUIButtonColor
{
#region prop
public static UIButton PreviousButton {
get
{
return _previousButton
}
set
{
_previousButton = value;
}
}
public static UIButton CurrentButton
{
get
{
return _currentButton;
}
set
{
_currentButton = value;
}
}
public static bool SwapColor (UIButton sender, bool isPrevBakGraound)
{
if (isPrevBakGraound == false)
{
InitApplyColorBorder (sender);
SwapUIButtonColor.PreviousButton = sender;
return true;
}
else
{
if (SwapUIButtonColor.PreviousButton != sender)
{
InitApplyColorBorder (sender);
SwapUIButtonColor.CurrentButton = PreviousButton;
PreviousButton = sender;
SwapUIButtonColor.CurrentButton.Layer.BorderColor = (UIColor.Black).CGColor;
SwapUIButtonColor.CurrentButton.Layer.BorderWidth = 0f;
SwapUIButtonColor.CurrentButton.Layer.CornerRadius = 0f;
}
else if (SwapUIButtonColor.PreviousButton == sender)
{
InitApplyColorBorder (sender);
SwapUIButtonColor.PreviousButton = sender;
}
return true;
}
}
static void InitApplyColorBorder (UIButton sender)
{
sender.Layer.BorderColor = (UIColor.Red).CGColor;
sender.Layer.BorderWidth = 1.0f;
sender.Layer.CornerRadius = 10f;
}
Also from ViewDidload Method Call this above method on UIButton Click events
private bool isPrevBakGraound = false;
isPrevBakGraound = SwapUIButtonColor.SwapColor (btnReset, isPrevBakGraound);