【发布时间】:2011-06-03 21:58:40
【问题描述】:
可能重复:
custom UITextField with image as a background blinking cursor issue
我有一个 UIImageView(图像中有图案、渐变和阴影)。我添加了一个 UITextField 作为这个 UIImageView 的子视图,并将 textField 背景设置为清除,以便它被看穿,代码是:
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(10, 12, 359 , 36)];
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.textColor = [UIColor whiteColor];
textField.placeholder = @"USERNAME";
textField.backgroundColor = [UIColor clearColor];
textField.font = [UIFont systemFontOfSize:15];
textField.delegate = self;
[username_background addSubview:textField];
问题是当我开始编辑 UITextField 时,我遇到了以下布局问题:
编辑前:
编辑时:
如果我将 UIColor clearColor 背景更改为其他颜色,我可以解决此问题,但显然我发现很难为背景获取合适的颜色。我确实尝试过:
[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bkg-username.png"]];
但是,我得到的是:
【问题讨论】:
标签: iphone objective-c uiimageview uitextfield