UITextField text colour goes invisible when editing - is this a bug?

不想你离开。 提交于 2019-12-11 08:47:08

问题


I have a UITableView which is set up to resemble drawing on a blackboard. The cells contain a UITextField which has the textColor property set to a pattern image:

textField.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"chalkTexture.png"]];

This all works fine. However, the cell is editable in-place, and doing this makes the text invisible! I have removed all possible background items so I know it isn't being overlapped by anything, or drawing black on a black background, for example.

I can "solve" the problem by changing the text colour in my delegate methods like so:

-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    textField.textColor = [UIColor whiteColor];
}

-(void)textFieldDidEndEditing:(UITextField *)textField
{
    textField.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"chalkTexture.png"]];
}

This doesn't look too bad and does emphasise the cell that is being edited, but I'd like to keep the textured colour for my text. Is this a bug or intentional behaviour?

来源:https://stackoverflow.com/questions/7444473/uitextfield-text-colour-goes-invisible-when-editing-is-this-a-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!