略微多一点获得核准后,API的友好之处是,使用普通的UIText Field,使用以下代码在UIText Field添加一个标签(如果你想要清除放大玻璃,你会吸引到搜索箱中去吗?)
UILabel *searchFieldLeftLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 32, 15)];
searchFieldLeftLabel.text = @"find:";
searchFieldLeftLabel.placeholder = @"e.g. wings, Boathouse";
searchFieldLeftLabel.font = [UIFont systemFontOfSize:14];
searchFieldLeftLabel.textColor = [UIColor grayColor];
self.searchFieldLeftLabel.leftView = locationSearchFieldLeftLabel;
[searchFieldLeftLabel release];
其结果是一个 n色的方框,它看着:
And when you start typing text, it replaces the placeholder, but the label remains: