添加通知
//开始编辑
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(beginediting:) name:UITextViewTextDidBeginEditingNotification object:nil];//停止编辑
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(endediting:) name:UITextViewTextDidEndEditingNotification object:nil];
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
// [self.messageTV endEditing:YES];
[self.messageTV resignFirstResponder];
}
-(void)beginediting:(NSNotification *)notification{
NSLog(@"开始编辑");
[UIView animateWithDuration:0.5 animations:^{
self.view.frame = CGRectMake(0, -250, WG_WIDTH, WG_HEIGHT);
self.topview.frame = CGRectMake(0, 250, WG_WIDTH, 64);
self.TVBGLabel.text = @"";
}];
}
-(void)endediting:(NSNotification *)notification{
self.view.frame = CGRectMake(0, 0, WG_WIDTH, WG_HEIGHT);
self.topview.frame = CGRectMake(0, 0, WG_WIDTH, 64);
NSLog(@"停止编辑");
}
//释放通知
-(void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}