I am using swift 4 & getting the following error:
Instance member 'height' cannot be used on type 'CGRect'
When using the below code:
let userInfo = notification.userInfo!
let keyboardFrame = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue
let keyboardFrame = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue
let changeInHeight = (CGRect.height(keyboardFrame) + 40) * (show ? 1 : -1)
I cannot figure out why, any help much appreciated!
height
is a property of a CGRect
structure. You are accessing it like it is a class method. Since keyboardFrame
is of type CGRect
, you want keyboardFrame.height
instead.
let changeInHeight = (keyboardFrame.height + 40) * (show ? 1 : -1)