If I understand you correctly, you want to make the button's background transparent and have no border. If so, I think I found a solution:
For iOS6:
You have to set the backgroundImage
property to image with a transparent background.
For example you can do it with an UIImage
object made with [UIColor clearColor]
.
For iOS7:
Just change nothing, but tintColor
:)
How to do it?
Firstly, I used a method from here: LINK, but changed it a little bit to:
- (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size
{
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Then in viewDidLoad I wrote:
if ([[[UIDevice currentDevice] systemVersion] doubleValue] < 7.0) {
[[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundImage:[self imageWithColor:[UIColor clearColor] andSize:CGSizeMake(30.f, 40.f)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
} else {
[[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:[UIColor whiteColor]];
}
I hope it will solve your problem :)