我已经这样做了。我知道你已经得到的答案uptil现在 但仍这将有助于别人这样 这是可以做到如下
-(void)viewWillAppear:(BOOL)animated
{
imgVw =[[UIImageView alloc]initWithFrame:CGRectMake(68, 7, 180, 28)];
[imgVw setImage:[UIImage imageNamed:@"textfieldBackground.png"]];
[self.navigationController.navigationBar addSubview:imgVw];
textfieldTxt = [[UITextField alloc]initWithFrame:CGRectMake(78, 11, 170, 25)];
textfieldTxt.backgroundColor = [UIColor clearColor];
[textfieldTxt setAutocorrectionType:UITextAutocorrectionTypeNo];
textfieldTxt.delegate = self;
[self.navigationController.navigationBar addSubview:textfieldTxt];
}
不要忘了从上海华盈,除去viewdidunload时请
- (void)viewDidUnload
{
[super viewDidUnload];
[textfieldTxt removeFromSuperview];
[imgVw removeFromSuperview];
}
谢谢
您是否添加了一些文字? – typeoneerror 2010-06-18 22:52:17
我没有添加任何文字。我想覆盖它与搜索图标(放大镜),但无法弄清楚,如果我可以做到这一点,而无需添加PNG图标。默认的搜索栏更圆,但我希望它看起来更像一个文本字段。 谢谢! David – prostock 2010-06-19 07:25:04