I'm trying to make buttons with titles that would change their width, height and font size of the title text depending on iOS device (autoscaling). I'm using Xcode 10 coding Swift.

Here is the simple example: I created in IB red button that covers the whole screen (top, bottom, leading and trailing constraints are set to 0) with the title "Button" in the center with the font size set to 350. The title would fit width of 12.9" iPad perfectly (see the pic).

![IB](https://i.stack.imgur.com/UHh3T.png)

I entered FitToWidth code like this:

```
class ViewController: UIViewController {

@IBOutlet weak var button: UIButton!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    button.titleLabel?.adjustsFontSizeToFitWidth = true
    button.titleLabel?.minimumScaleFactor = 0.1
}

```

When I run the code on device with lower screen resolution than iPad 12.9" I see that the button title is scaled and fits the screen width but it is shifted down (see the pics).

**iPad 12.9 simulation**

![iPad 12.9 simulation](https://i.stack.imgur.com/vKUuH.png)

**iPhone SE simulation**

![iPhone SE simulation](https://i.stack.imgur.com/SkuFB.png)

What am I missing?

I need title text to be situated in the center of the button as I did it in IB. I tried various constraints applied to the button but nothing worked out.