for (UIView *subview in self.searchBar.subviews) { if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) { [subview removeFromSuperview]; } if ([subview isKindOfClass:[UITextField class]]) { UITextField *textField = (UITextField *)subview; textField.borderStyle = UITextBorderStyleRoundedRect; UILabel *iView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 35, 20)]; [iView setText:@"search"]; [iView setFont:[UIFont systemFontOfSize:15.0]]; [iView setTextColor:[UIColor grayColor]]; textField.leftView = iView; textField.clearButtonMode = UITextFieldViewModeNever; // textField.rightViewMode = UITextFieldViewModeAlways; textField.returnKeyType = UIReturnKeyDone; } }