Search code examples
iosobjective-cios7uisearchbar

Set rounded corners and border to background(Not the UITextField) of UISearchBar in ios7


How can i apply rounded corners and a border to the background of UISearchBar in ios7? I am able to change the background color of the bar.

Something like this

enter image description here

Thanks


Solution

  •   UISearchBar *searchBar  = [[UISearchBar alloc] init];
      searchBar.layer.cornerRadius  = 6;
      searchBar.clipsToBounds       = YES;
      [searchBar.layer setBorderWidth:1.0];
      [searchBar.layer setBorderColor:[[UIColor lightGrayColor].CGColor];