房间内发言框弹出动画

This commit is contained in:
zu
2021-11-05 17:05:26 +08:00
parent e767258438
commit 6bdf8cccf5

View File

@@ -43,7 +43,7 @@
}
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)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<RoomHostDelegate>)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);