2012-01-30 141 views
3

我在使用MonoTouch以编程方式硬编码UIButton的颜色时遇到了问题。标准的RectRound按钮是白色的,我需要这个按钮是蓝色的。这里是我的代码:MonoTouch中的自定义UIButton颜色

 private void CreateButton() { 
     RectangleF viewFrame = this.subView.Frame; 
     RectangleF buttonFrame = new RectangleF (10f, viewFrame.Bottom - 200f, viewFrame.Width - 20f, 50f); 

     this.buttonChangeColor = UIButton.FromType (UIButtonType.RoundedRect); 
     this.buttonChangeColor.Frame = buttonFrame; 
     this.buttonChangeColor.SetTitle ("Tap to change view color", UIControlState.Normal); 
     this.buttonChangeColor.SetTitle ("Changing color...", UIControlState.Highlighted); 
     this.buttonChangeColor.SetTitleColor (UIColor.Red, UIControlState.Normal); 
//This here is my attempt. The rounded rectangle remains white and I can see some blue peeking out from behind but I need the button to be blue, not the background 
     this.buttonChangeColor.BackgroundColor = UIColor.Blue; 
     this.buttonChangeColor.TouchUpInside += this.buttonChangeColor_TouchUpInside; 
     this.subView.AddSubview (this.buttonChangeColor); 

    } 

非常感谢您的帮助!

回答