title: Different behavior of UISearchBar with XIB and code
body: <p>I am unable to understand the behavior of <code>UISearchBar</code>'s bar tint property.</p>
  
  <p>I am enclosing a screenshot of my simulator output.</p>
  
  <p><img src="https://i.stack.imgur.com/UnPIP.png" alt="enter image description here"></p>
  
  <p>The first search bar was done in XIB. It basically consists of a <code>UISearchBar</code> inside a <code>UIView</code>. The <code>UIView</code>'s background is set to red color and <code>UISearchBar</code>'s bar tint color has been set to clear color. Everything else is default. I am attaching the screenshot of XIB. This is what I am trying to achieve by means of code.</p>
  
  <p><img src="https://i.stack.imgur.com/AM8Jz.png" alt="enter image description here"></p>
  
  <p>I tried working by code in all combinations and in no way I am able to get what I got through XIB. In the first attempt by code, I am just rewriting the stuff what I did by XIB. But I get a black colored search bar as shown in simulator. In the second attempt by code, I am setting the bar tint color to red color, but I am getting black line on border.</p>
  
  <pre><code>- (void)viewDidLoad
  
  {
  
  [super viewDidLoad];
  
  UIView *searchBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 200, 320, 64)];
  searchBarView.backgroundColor = [UIColor redColor];
  UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 15, 320, 44)];
  [searchBar setBarTintColor:[UIColor clearColor]];
  [searchBarView addSubview:searchBar];
  [self.view addSubview:searchBarView];
  
  UIView *searchBarView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 300, 320, 64)];
  searchBarView2.backgroundColor = [UIColor redColor];
  UISearchBar *searchBar2 = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 15, 320, 44)];
  [searchBar2 setBarTintColor:[UIColor redColor]];
  [searchBarView2 addSubview:searchBar2];
  [self.view addSubview:searchBarView2];
  }
  </code></pre>
  
  <p>1) How is that my first attempt by code though similar with XIB, yet gives me totally different result? What am I missing?</p>
  
  <p>2) By my second attempt by code, how do I get rid of the black line?</p>