Try below code to achieve shadow effect on roundRect textfield.
    //Basic texfield Setup 
    textField.borderStyle = .none
    textField.backgroundColor = UIColor.groupTableViewBackground // Use anycolor that give you a 2d look.
    //To apply corner radius
    textField.layer.cornerRadius = textField.frame.size.height / 2
    //To apply border
    textField.layer.borderWidth = 0.25
    textField.layer.borderColor = UIColor.white.cgColor
    //To apply Shadow
    textField.layer.shadowOpacity = 1
    textField.layer.shadowRadius = 3.0
    textField.layer.shadowOffset = CGSize.zero // Use any CGSize
    textField.layer.shadowColor = UIColor.gray.cgColor
    //To apply padding
    let paddingView : UIView = UIView(frame: CGRect(x: 0, y: 0, width: 20, height: textField.frame.height))
    textField.leftView = paddingView
    textField.leftViewMode = UITextFieldViewMode.always
Note: For some reason textField.borderStyle = .none not taking effect even setting the code in viewWillLayoutSubviews() or viewDidLayoutSubviews().So, I recommend you to set borderStyle through storyBoard textfield Attributes inspector.

Output from real device:

To achieve a drop shadow effect:(like other SO posts)
   textField.layer.borderColor = UIColor.black.withAlphaComponent(0.25).cgColor
   textField.layer.shadowOffset = CGSize(width: 0, height: 3)
   textField.layer.shadowColor = UIColor.black.cgColor //Any dark color
Output:
