title: Search bar with corner radius in swift
body: <p><a href="https://i.stack.imgur.com/P2dgS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P2dgS.png" alt="Example Image"></a></p>
  
  <p>I want to create a view like the above image.it has a search bar with corner radius.but when i am trying to create, i am unable to make the search bar with corner radius.also i am unable to make the text field of the search bar with corner radius. i have writtenall my code in viewDidAppear method. It is ok or i have to write it in  viewWillLayourSubview. so that i will be able to make the exact
  same search bar like this image. also i want the seach icon to be placed slightly right.</p>
  
  <p>My code is:</p>
  
  <pre><code>override func viewDidAppear(_ animated: Bool) {
  super.viewDidAppear(true)
  
  for subView in searchBar.subviews  {
  
  
      for subsubView in subView.subviews  {
          if let textField = subsubView as? UITextField {
              var bounds: CGRect
              var placeHolder = NSMutableAttributedString()
              let Name  = "Search"
              placeHolder = NSMutableAttributedString(string:Name, attributes: [NSAttributedString.Key.font:UIFont(name: "Helvetica", size: 15.0)!])
  
  
              placeHolder.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.gray, range:NSRange(location:0,length:Name.count))
  
              textField.attributedPlaceholder = placeHolder
  
              if let leftView = textField.leftView as? UIImageView {
                  leftView.image = leftView.image?.withRenderingMode(.alwaysTemplate)
  
                  leftView.frame.size.width = 15.0
                  leftView.frame.size.height = 15.0
                  leftView.tintColor = UIColor.gray
  
              }
              textField.layer.cornerRadius = 50.0
  
              bounds = textField.frame
              bounds.size.width = searchBar.frame.width
              bounds.size.height = searchBar.frame.height
              textField.bounds = bounds
              textField.borderStyle = UITextField.BorderStyle.roundedRect
  
              searchBar.backgroundImage = UIImage()
              textField.backgroundColor =  UIColor.lightGray.withAlphaComponent(0.2)
              searchBar.searchTextPositionAdjustment = UIOffset(horizontal: 5, vertical: 0)
  
          }
      }
  }
   }*
  </code></pre>