I have a third-party keyboard and I want to make the buttons proportional to the width of the keyboard (which changes based on device/orientation).
I pass along the buttons to the function:
func addIndividualButtonConstraints(buttons: [UIButton], mainView: UIView) {
let buttonWidth = mainView.frame.width / 12
...
}
mainView is equal to the width of my keyboard (set in IB). But mainView.frame.width gives me 320, even if the width of the keyboard is actually 414 (as in iPhone 6s Plus).
It seems that it's just using the dimensions of the keyboard that I've set in IB (which is 320 x 200), and only later at run-time does the keyboard expand to fit the device.
How do I get these run-time dimensions and pass them into my function?