Agus
Agus

Reputation: 1614

Text Field background color not change it with UI Text Border Style Rounded Rect

I am trying to change the background color in IUTextField but I only success if I not set UITextBorderStyleRoundedRect.

theTextField.borderStyle=UITextBorderStyleNone;

I tried to do it within IBuilder and

theTextField.backgroundColor=[UIColor colorWithRed:m_r green:m_g blue:m_b alpha:1.0];

It's happened on IOS 4.X not in IOS 5.X Any idea what could be doing?

Upvotes: 0

Views: 2013

Answers (1)

Mrunal
Mrunal

Reputation: 14118

I have done a sample code and it was working fine to me with all the iOS version >= 3.2

Here is the code

- (IBAction)button:(id)sender {

  if ([[textField backgroundColor] isEqual:[UIColor greenColor]]) {

    [textField setBackgroundColor:[UIColor yellowColor]];
  }
  else {

    [textField setBackgroundColor:[UIColor greenColor]];

  }
}

Here textField is an IBOutlet connection which is available in my xib file.

Also added a UIButton which have this action method connected. And It works perfectly for me..

I would suggest you to try a sample with this code.

Upvotes: 1

Related Questions