0
我有一個文本框(稱爲countTotalFieldUniversal),我想改變顏色,當我點擊編輯按鈕佔位符文本。將文字灰色的「編輯按鈕」,點擊
目前,我的代碼是:
- (void)setEditing:(BOOL)flag animated:(BOOL)animated
{
NSLog(@"setEditing called");
[super setEditing:flag animated:animated];
if (flag == YES){
NSLog(@"Flag is yes");
[countTotalFieldUniversal setValue:[UIColor darkGrayColor]
forKeyPath:@"_placeholderLabel.textColor"];
NSLog(@"Color should be grey...");
}
else {
// Edit not selected
}
}
我的控制檯打印出的是「國旗是yes」和「顏色應該是灰色的......」但文字不會改變。 我是否正確設置文本?
您可能需要告訴現場才能拿起你的鍵/值更改爲重繪:'[self.countTotalFieldUniversal setNeedsDisplay]'。 –
我補充說,在以前的NSLog權(@「顏色應該是灰色的......」);,但它並沒有改變。但是,我不得不[countTotalFieldUniversal setNeedsDisplay]。它不會接受self.countTotalFieldUniversal ...... – AllieCat
我同意你的看法,我需要「刷新」,以表視圖。我只是不知道如何... – AllieCat