I have a UITextField
where I set the inputView
to a custom view. This has a standard height of 216. I would like to set this to something like 300, or half the screen.
Using constraints is not an option, as it conflicts with the default 216 and it discards my constraint.
Setting the frame also does not work.
Is there some way to set this to a higher value?
You need subclassed UIInputView
and overrided allowsSelfSizing
for return value true, like this
class MyInputView: UIInputView {
// ... other code
override var inputViewStyle: UIInputViewStyle { get { return .default } }
override var allowsSelfSizing: Bool { get { return true } set{} }
// ... other code
}
I got it to work by setting the autoResizingMask
to None
, and setting the frame
to the desired frame (using UIScreen.mainScreen
to get the width of the screen). I did both these things before layoutSubviews
gets called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With