如何以編程方式更改位於UITableViewCell中的UITextField的backgroundColor?爲UITableViewCell中的UITextField設置backgroundColor
設置UITextField.backgroundColor似乎不起作用。
如何以編程方式更改位於UITableViewCell中的UITextField的backgroundColor?爲UITableViewCell中的UITextField設置backgroundColor
設置UITextField.backgroundColor似乎不起作用。
我有同樣的問題。我通過創建自己的UITextField並將其添加到UITableViewCell來解決它,但我不知道是否有更好的方法來完成它。
試試在layoutSubviews方法中使用這個單元格。
- (void)layoutSubviews {
[super layoutSubviews];
self.textLabel.backgroundColor = [UIColor blackColor];
}
相同的效果,textField未填充(即使框架區域(特別是角落)顯示顏色 – iFloh 2010-04-26 10:46:03
創建了自己的?你重寫了什麼? – iFloh 2010-04-26 10:24:55
你只需要將子視圖添加到單元格contentView中,如下所示: [cell.contentView addSubview:yourTextView]; yourTextView是一個UILabel,您初始化,設置其CGRect,設置其文本,並設置其backgroundColor – Sorig 2010-04-26 16:06:56