views:

131

answers:

2

How can I programatically change the backgroundColor of an UITextField that sits in a UITableViewCell?

Setting the UITextField.backgroundColor doesn't seem to work.

+1  A: 

I had the same problem. I sovled it by creating my own UITextField and adding it to the UITableViewCell, but im not sure if there's a better way to do it.

Sorig
created your own? What did you override?
iFloh
You just add a subview to the cells contentView, like this:[cell.contentView addSubview:yourTextView];yourTextView is a UILabel that you initialize, set its CGRect, set its text, and set its backgroundColor
Sorig
+1  A: 

Try do it in layoutSubviews method of this cell.

- (void)layoutSubviews {
    [super layoutSubviews];
    self.textLabel.backgroundColor = [UIColor blackColor];
}
Skie
same effect, the textField is not filled (even though the frame areas (especially corners) shows the color
iFloh