Answer the question
In order to leave comments, you need to log in
How to change keyboard height in swift 3?
How to change keyboard height in swift 3? The task is to make it so that when you press a button on the keyboard, the view is resized to full screen.
I do it through NSLayoutConstraint
var screenWidth = UIScreen.main.bounds.size.width;
var screenHeight = UIScreen.main.bounds.size.height;
var heightConstraint: NSLayoutConstraint?
func setUpHeightConstraint()
{
if (heightConstraint == nil)
{
heightConstraint = NSLayoutConstraint(item: view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: screenHeight);
heightConstraint?.priority = UILayoutPriority(UILayoutPriorityRequired);
view.addConstraint(heightConstraint!);
}
else
{
heightConstraint?.constant = screenHeight;
}
heightConstraint?.constant = screenHeight;
print(">>: \(view.frame.size)");
}
Answer the question
In order to leave comments, you need to log in
Probably forgot to insert before adding the constraints:
view.translatesAutoresizingMaskIntoConstraints = false
Yes, I inserted it, it didn’t really help, or rather, the application behaved strangely, in one assembly, the height changed, then reselected (added print () with text), compiled and again does not change
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question