2012-01-30 35 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); 

    } 

非常感謝您的幫助!

回答