swift -> 键盘类(UIInputViewController) 初始键盘高度和 修改 高度

初始化 高度 

class KeyboardViewController: UIInputViewController {    
    override func updateViewConstraints() {
        super.updateViewConstraints()
        print("view update view");
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        print("view will appear");
        self.inputView!.addConstraint(windowConstraintsHeight);
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //检查拼音是否合法的参考拼音数组
       
        //---- 设置键盘弹出高度 -------
        let dummyView = UILabel(frame:CGRect.zero)
        dummyView.translatesAutoresizingMaskIntoConstraints = false;
        self.view.addSubview(dummyView);
        windowConstraintsHeight = NSLayoutConstraint( item:self.inputView!, attribute:.height, relatedBy:.equal, toItem:nil, attribute:.notAnAttribute, multiplier:0.0, constant:CGFloat(500))//500是 键盘高度

中途修改 高度

            
            self.inputView?.removeConstraint(windowConstraintsHeight)
          
            windowConstraintsHeight = NSLayoutConstraint( item:self.inputView!, attribute:.height, relatedBy:.equal, toItem:nil, attribute:.notAnAttribute, multiplier:0.0, constant:CGFloat(800))
            //
            self.viewWillAppear(true);
            self.updateViewConstraints();
            //主窗口跳转到另外一个View(ViewController(),)
            self.present(ViewController(), animated: true, completion: nil);

猜你喜欢

转载自mft.iteye.com/blog/2368193