title: iOS InputAccessory view wrong orientation
body: <p>I have a view which can be rotated while whole other application is not.
  The rotation being done using view transform rather than rotation whole viewController.
  The issue is that in a landscape mode keyboard's inputaccessory view has wrong orientation - keyboard is being shown correctly in landscape mode, while inputAccessory view is being shown as in portrait:</p>
  <p><a href="https://i.stack.imgur.com/oFmPp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oFmPp.png" alt="enter image description here" /></a></p>
  <p>In portrait orientation all looks correctly:</p>
  <p><a href="https://i.stack.imgur.com/1syUi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1syUi.png" alt="enter image description here" /></a></p>
  <p>I'm using extension to build input accessory view:</p>
  <pre><code>extension UITextField
  {
      static var _doneAccessoryViewButtonCallback = [String:()-&gt;Void]()
      
      var doneAccessoryViewButtonCallback:(()-&gt;Void)? {
          get {
              let tmpAddress = String(format: &quot;%p&quot;, unsafeBitCast(self, to: Int.self))
              return UITextField._doneAccessoryViewButtonCallback[tmpAddress]
          }
          set(newValue) {
              let tmpAddress = String(format: &quot;%p&quot;, unsafeBitCast(self, to: Int.self))
              UITextField._doneAccessoryViewButtonCallback[tmpAddress] = newValue
          }
      }
      
      @IBInspectable var doneAccessory: Bool{
          get{
              return self.doneAccessory
          }
          set (hasDone) {
              if hasDone{
                  addDoneButtonOnKeyboard()
              }
          }
      }
      
      
      func addDoneButtonOnKeyboard()
      {
          let view:UIView = UIView()
          view.frame = CGRect(x: CGFloat(0), y: CGFloat(0), width: UIScreen.main.bounds.width, height: CGFloat(44))
          view.backgroundColor = UIColor.RGB(hexString: &quot;#D1D5DB&quot;)
          
          let button: UIButton = self.getButton()
          
          view.addSubview(button)
          button.translatesAutoresizingMaskIntoConstraints = false
          button.constrainToRightOfSuperView(CGFloat(16))
          button.centerVerticallyInSuperView()
          
          
          self.inputAccessoryView = view
          
          let version = OperatingSystemVersion(majorVersion: 13, minorVersion: 0, patchVersion: 0)
          if ProcessInfo.processInfo.isOperatingSystemAtLeast(version) {
              view.translatesAutoresizingMaskIntoConstraints = false
              view.stretchToBoundsOfSuperView()
          } else {
              view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
          }
      }
      
      func isEmpty() -&gt; Bool
      {
          return self.text == nil || self.text!.count == 0
      }
      
      // MARK: -
      // MARK: - PRIVATES
      private func getButton() -&gt; UIButton
      {
          let button = UIButton(type: .custom)
          
          let attString:NSMutableAttributedString = NSMutableAttributedString(string: &quot;Done&quot;)
          attString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.RGB(0xed, g: 0x3c, b: 00), range: NSRange(location: 0, length: attString.string.length))
          attString.addAttribute(NSAttributedString.Key.font, value: UIFont(name: &quot;Avenir-Book&quot;, size: 17)!, range: NSRange(location: 0, length: attString.string.length))
          button.setAttributedTitle(attString, for: .normal)
          button.addTarget(self, action: #selector(doneButtonAction), for: .touchUpInside)
          
          return button
      }
      
      @objc func doneButtonAction()
      {
          self.resignFirstResponder()
          self.doneAccessoryViewButtonCallback?()
      }
  }
  </code></pre>