#pragma mark=======To set BGs for searchBar=======
+(void)customizeSearchBar :(UISearchBar *)searchBar;
{
//To add backfround color to the SEARCH BAR & SEARCH FIELD
searchBar.backgroundImage = [UIImage imageNamed:@"clearColor.png"];
[searchBar setSearchFieldBackgroundImage:[UIImage imageNamed:@"search_bar.png"] forState:UIControlStateNormal];
//To remove search icon and change the position of the cursor
UITextField *textfield=(UITextField*)[[searchBar subviews] objectAtIndex:1];
textfield.leftView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"clearColor.png"]];
//To change font color of searche text & place holder
for(UIView *subView in searchBar.subviews)
{
if([subView isKindOfClass:UITextField.class])
{
//Searched Font
[(UITextField*)subView setTextColor: [UIColor colorWithRed:83/255.0f green:44/255.0f blue:27/255.0f alpha:1.0f] ];
//Place holder
[(UITextField*)subView setValue:[UIColor colorWithRed:83/255.0f green:44/255.0f blue:27/255.0f alpha:0.5f] forKeyPath:@"_placeholderLabel.textColor"];
}
}
}
No comments:
Post a Comment