问题 TextField 更改为搜索文本
Posted
技术标签:
【中文标题】问题 TextField 更改为搜索文本【英文标题】:Problem TextField changing into search text 【发布时间】:2011-06-25 09:39:55 【问题描述】:我正在为我的文本创建文本字段。
当我创建它时,它会显示一条附加到我的文本字段的线。
我将图像附加到此..
我的代码是
-(void)createTextField
if (([[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeLeft)||([[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeRight))
[text setFrame:CGRectMake(640, 15, 300,40)];
else
[text setFrame:CGRectMake(390,15,300,50)];
text.font = [UIFont systemFontOfSize:20];
text.layer.cornerRadius = 20;
text.delegate=self;
[text setTextColor:[UIColor blackColor]];
text.alpha=1.0;
text.autocorrectionType = UITextAutocorrectionTypeNo;
text.returnKeyType=UIReturnKeySearch;
UIImageView *searchLogo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon-search-black.png"]];
[text setLeftView:searchLogo];
[text setLeftViewMode:UITextFieldViewModeAlways];
[searchLogo release];
text.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
text.borderStyle=UITextBorderStyleRoundedRect;
[text setBackgroundColor:[UIColor whiteColor]];
[text setHidden:NO];
[self addSubview:text];
[text becomeFirstResponder];
【问题讨论】:
你也可以给你看一下文本框的 html 吗? 【参考方案1】:一定是borderStyle
加入,即
text.borderStyle = UITextBorderStyleRoundedRect;
您可以使用UITextBorderStyleNone
,因为您已经使用cornerRadius
自定义了边框样式。
【讨论】:
以上是关于问题 TextField 更改为搜索文本的主要内容,如果未能解决你的问题,请参考以下文章
当单击带有 TextField 的警报时,UIPickerView 更改为正常的 textField
在 Flutter 中将焦点从一个文本字段更改为下一个文本字段