title: Remove top and bottom border of UISearchBar and shadow?
body: <p>I have created a .xib with a UISearchBar.</p>
  
  <p>I am looking to remove the top and bottom borders as seen in this image: <a href="https://i.stack.imgur.com/Zso86.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Zso86.png" alt="image"></a></p>
  
  <p>There is also what looks like a shadow underneath the top border.</p>
  
  <p>I have tried changing backgrounds/tint colours etc, but struggling to get it to disappear.</p>
  
  <p>Any help would be welcome, any ideas?</p>
  
  <p>EDIT</p>
  
  <p>So the code below allows me to get rid of the border at the top and bottom, but not the weird drop shadow. I've added green background to show it more clearly.</p>
  
  <p><a href="https://i.stack.imgur.com/KM3sA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KM3sA.png" alt="See"></a></p>
  
  <p>Also, what would be the best way to add a border around the text box (rather than the view)?? Thanks</p>
  
  <p>//** This is what I'm trying to do: <a href="https://stackoverflow.com/questions/33107058/uiviewcontroller-sizing-as-maincontroller-within-uisplitviewcontroller">https://stackoverflow.com/questions/33107058/uiviewcontroller-sizing-as-maincontroller-within-uisplitviewcontroller</a></p>
  
  <p>and here is the code I am using.</p>
  
  <pre><code>import UIKit
  
  class TopSearchViewController: UIView {
  
      var expanded: Int = 0
  
      @IBOutlet weak var trailingConstraint: NSLayoutConstraint!
      @IBOutlet var contentView: UIView!
      @IBOutlet weak var searchBar: UISearchBar!
  
      @IBAction func advancedSearchButton(sender: AnyObject) {
          if expanded == 0 {
              self.layoutIfNeeded()
              UIView.animateWithDuration(0.1, animations: {
                  self.trailingConstraint.constant = 200
                  self.layoutIfNeeded()
              })
              expanded = 1
          } else {
              self.layoutIfNeeded()
              UIView.animateWithDuration(0.1, animations: {
                  self.trailingConstraint.constant = 25
                  self.layoutIfNeeded()
              })
              expanded = 0
          }
      }
  
      override init(frame: CGRect) { // for using CustomView in code
          super.init(frame: frame)
          self.commonInit()
      }
  
      required init(coder aDecoder: NSCoder) { // for using CustomView in IB
          super.init(coder: aDecoder)
          self.commonInit()
      }
  
      private func commonInit() {
          NSBundle.mainBundle().loadNibNamed("TopSearchViewController", owner: self, options: nil)
  
          contentView.frame = self.bounds
          contentView.autoresizingMask = .FlexibleHeight | .FlexibleWidth
  
          self.addSubview(contentView)
  
          self.searchBar.layer.borderWidth = 1
          self.searchBar.layer.borderColor = UIColor.whiteColor().CGColor
  
          println(searchBar)
  
          for subview in searchBar.subviews {
              println("hello")
  
              var textField : UITextField
  
              if (subview.isKindOfClass(UITextField)) {
                  textField = subview as! UITextField
                  textField.borderStyle = .None
                  textField.layer.borderWidth = 1
                  textField.layer.borderColor = UIColor.lightGrayColor().CGColor
                  textField.layer.cornerRadius = 14
                  textField.background = nil;
                  textField.backgroundColor = UIColor.whiteColor()
              }
          }
  
      }
  
      func viewDidLoad() {
  
      }
  }
  </code></pre>