Change background image of searchbar

dev.yefeng picture dev.yefeng · Mar 8, 2011 · Viewed 9.3k times · Source

It's easy to change background color of a searchbar.But, I have no idea how to change its background image.There is no direct method. I need help............... I appreciate any given idea...

Answer

bonny picture bonny · Mar 8, 2011
UISearchBar* bar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
UIImageView* iview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"test.png"]];
iview.frame = CGRectMake(0, 0, 320, 44);
[bar insertSubview:iview atIndex:1];
[iview release];
[self.view addSubview:bar];
[bar release];