|
@@ -25,8 +25,9 @@ class CommentInputView: UIView {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ /// 添加视图的高度
|
|
|
+ var screenHeight : CGFloat = 0
|
|
|
|
|
|
-
|
|
|
|
|
|
typealias CommentInputViewClosure = (String) -> ()
|
|
|
var commentInputViewClosure :CommentInputViewClosure?
|
|
@@ -40,19 +41,15 @@ class CommentInputView: UIView {
|
|
|
}
|
|
|
|
|
|
/// 初始化是否隐藏
|
|
|
- init(isHidden:Bool,height:CGFloat = 0) {
|
|
|
+ init(isHidden:Bool,height:CGFloat = kScreenHeight) {
|
|
|
self.init()
|
|
|
inputViewIsHidden = isHidden
|
|
|
- if height == 0 {
|
|
|
- if isHidden {
|
|
|
- self.frame = CGRect(x: 0, y: kScreenHeight, width: kScreenWidth, height: kSafeTabBarHeight+48)
|
|
|
- } else {
|
|
|
- self.frame = CGRect(x: 0, y: kScreenHeight-kSafeTabBarHeight-48, width: kScreenWidth, height: kSafeTabBarHeight+48)
|
|
|
- }
|
|
|
- }else {
|
|
|
- self.frame = CGRect(x: 0, y: height-kSafeTabBarHeight-48, width: kScreenWidth, height: kSafeTabBarHeight+48)
|
|
|
+ screenHeight = height
|
|
|
+ if isHidden {
|
|
|
+ self.frame = CGRect(x: 0, y: screenHeight, width: kScreenWidth, height: kSafeTabBarHeight+48)
|
|
|
+ } else {
|
|
|
+ self.frame = CGRect(x: 0, y: screenHeight-kSafeTabBarHeight-48, width: kScreenWidth, height: kSafeTabBarHeight+48)
|
|
|
}
|
|
|
-
|
|
|
setupViews()
|
|
|
setupData()
|
|
|
}
|
|
@@ -111,7 +108,7 @@ class CommentInputView: UIView {
|
|
|
self?.sendButton.isEnabled = false
|
|
|
}
|
|
|
UIView.animate(withDuration: duration ?? 0, animations: {
|
|
|
- self?.y = kScreenHeight - (keyboardFrame?.size.height)! - (self?.height)! + kSafeTabBarHeight
|
|
|
+ self?.y = (self?.screenHeight)! - (keyboardFrame?.size.height)! - (self?.height)! + kSafeTabBarHeight
|
|
|
})
|
|
|
})
|
|
|
|
|
@@ -135,9 +132,9 @@ class CommentInputView: UIView {
|
|
|
}
|
|
|
UIView.animate(withDuration: duration ?? 0, animations: {
|
|
|
if self?.inputViewIsHidden ?? true {
|
|
|
- self?.y = kScreenHeight
|
|
|
+ self?.y = (self?.screenHeight)!
|
|
|
}else {
|
|
|
- self?.y = kScreenHeight - (self?.height)!
|
|
|
+ self?.y = (self?.screenHeight)! - (self?.height)!
|
|
|
|
|
|
}
|
|
|
})
|
|
@@ -156,7 +153,7 @@ class CommentInputView: UIView {
|
|
|
self.inputTextView.text = ""
|
|
|
self.inputTextView.height = 30
|
|
|
self.height = 48 + kSafeTabBarHeight
|
|
|
- self.y = kScreenHeight - self.height
|
|
|
+ self.y = screenHeight - self.height
|
|
|
self.endEditing(true)
|
|
|
}
|
|
|
|
|
@@ -180,6 +177,6 @@ extension CommentInputView : UITextViewDelegate {
|
|
|
textView.height = 30
|
|
|
}
|
|
|
self.height = (self.inputTextView.height) + kSafeTabBarHeight + 20
|
|
|
- self.y = kScreenHeight - (self.keyboardH) - (self.inputTextView.height) - 20
|
|
|
+ self.y = screenHeight - (self.keyboardH) - (self.inputTextView.height) - 20
|
|
|
}
|
|
|
}
|