diff --git a/xplan-ios/Main/Room/View/MenuContainerView/XPRoomSendTextView.m b/xplan-ios/Main/Room/View/MenuContainerView/XPRoomSendTextView.m index 8cb7de50..c521e19d 100644 --- a/xplan-ios/Main/Room/View/MenuContainerView/XPRoomSendTextView.m +++ b/xplan-ios/Main/Room/View/MenuContainerView/XPRoomSendTextView.m @@ -43,7 +43,7 @@ } - (instancetype)initWithDelegate:(id)delegate { - self = [super init]; + self = [super initWithFrame:CGRectMake(0, KScreenHeight - 40, KScreenWidth, 40)]; if (self) { self.delegate = delegate; [self addNotification]; @@ -86,37 +86,40 @@ self.editTextFiled.text = @""; [self.editTextFiled resignFirstResponder]; }]; - - } - (void)keyboardWillShow:(NSNotification *)notification { - [self.superview bringSubviewToFront:self]; - NSDictionary *info = [notification userInfo]; - CGFloat duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]; - CGRect endKeyboardRect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; - CGFloat h = endKeyboardRect.size.height; - [UIView animateWithDuration:duration animations:^{ - - [self mas_remakeConstraints:^(MASConstraintMaker *make) { - make.left.right.equalTo(self.superview); - make.height.equalTo(@40); - make.bottom.equalTo(self.superview).offset(-h); - }]; - }]; + [self.superview bringSubviewToFront:self]; + NSDictionary *info = [notification userInfo]; + NSValue *value = [info objectForKey:UIKeyboardFrameEndUserInfoKey]; + CGFloat keyBoardEndY = value.CGRectValue.origin.y; + NSNumber *curve = [info objectForKey:UIKeyboardAnimationCurveUserInfoKey]; + CGFloat duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]; + CGRect endKeyboardRect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; + CGFloat h = endKeyboardRect.size.height; + [UIView animateWithDuration:duration animations:^{ + [self mas_remakeConstraints:^(MASConstraintMaker *make) { + make.left.right.equalTo(self.superview); + make.height.equalTo(@40); + make.bottom.equalTo(self.superview).offset(-h); + }]; + [UIView setAnimationBeginsFromCurrentState:YES]; + [UIView setAnimationCurve:[curve intValue]]; + self.center = CGPointMake(self.center.x, keyBoardEndY - statusbarHeight - self.bounds.size.height/2.0); + }]; } //键盘隐藏 - (void)keyboardWillHidden:(NSNotification *)notification { - NSDictionary *info = [notification userInfo]; - CGFloat duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]; - [UIView animateWithDuration:duration animations:^{ - [self mas_remakeConstraints:^(MASConstraintMaker *make) { - make.bottom.left.right.equalTo(self.superview); - make.height.equalTo(@40); - }]; - self.hidden = YES; - }]; + NSDictionary *info = [notification userInfo]; + CGFloat duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]; + [UIView animateWithDuration:duration animations:^{ + [self mas_remakeConstraints:^(MASConstraintMaker *make) { + make.bottom.left.right.equalTo(self.superview); + make.height.equalTo(@40); + }]; + self.hidden = YES; + }]; } -(void)textFieldEditChanged:(NSNotification *)notification{ @@ -161,8 +164,6 @@ } } - - #pragma mark - Public Method + (void)showTextView:(UIView *)view delegate:(id)delegate { __block XPRoomSendTextView * textView; @@ -177,7 +178,7 @@ [view addSubview:textView]; } textView.hidden = NO; - + [textView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.mas_equalTo(view); make.height.mas_equalTo(40);