based on UISearchBar
I want to the following features
-
NO border,
origin searchbar has round corner textfield. this fragment code can make it no border, *but there is a problem: if set the bookmark button showed, the bookmark button border seems be cut 1 pixel too *UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(10, 5, 300, 45)]; UITextField *inputField = (UITextField *)[textField.subviews objectAtIndex:0]; inputField.backgroundColor = [UIColor clearColor]; inputField.layer.borderWidth = 5.0f; inputField.layer.cornerRadius = 14; inputField.layer.borderColor = [[UIColor whiteColor] CGColor]; -
custom bookmark button icon
- placeholder textColor
I have no idea about this. anybody has clues?
As of iOS 5 you’ve got the brilliant UIAppearance proxy that will let you set all that stuff with one line of code, but if you want to target 4 or below, then you’re rolling your own – you’re going to have to create your own custom view class, OR, do some subview hacking. You’ve already started in that first snippet, but there’s a problem…
The “proper” way to do subview hacking is to iterate over the
subviewsarray until you find a view that matches the one you’re looking for. In this case, what you want to do is something like:The problem with subview hacking is that the view hierarchy can change at any time, without warning, and suddenly (at best) your app doesn’t look the same or (at worst) it crashes. For this reason I’d recommend rolling your own or just targeting iOS 5 where this stuff is all really simple.