Swift 3.0 键盘弹起获取键盘高度

NotificationCenter.default.addObserver(self, selector: #selector(keybordShow(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)


//键盘弹起

func keybordShow(notification:Notification)  {

let userinfo: NSDictionary = notification.userInfo! as NSDictionary

let nsValue = userinfo.object(forKey: UIKeyboardFrameEndUserInfoKey) as! NSValue

let keyboardRec = nsValue.cgRectValue

let height = keyboardRec.size.height

print("keybordShow:\(height)")

}

UIView*backView = [[UIViewalloc]initWithFrame:CGRectMake(0,0, Main_Screen_Width,49)];

backView.backgroundColor= [UIColorredColor];

[self.tabBarinsertSubview:backViewatIndex:0];

self.tabBar.opaque=YES;

你可能感兴趣的:(Swift 3.0 键盘弹起获取键盘高度)