Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set height of custom inputView?

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?

like image 256
vrwim Avatar asked Oct 21 '15 14:10

vrwim


2 Answers

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
}
like image 114
EvGeniy Ilyin Avatar answered Sep 22 '22 15:09

EvGeniy Ilyin


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.

like image 22
vrwim Avatar answered Sep 22 '22 15:09

vrwim