0
我在一个滚动视图, 有几个UITextField
并通过设定每一次我得到了集中的任何文本框或取消键盘时的UITextField的边界Flash的
layer.borderColor = ...,
layer.borderRadius = 3.0,
layer.borderWidth = 0.1,
layer.masksToBounds = YES.
- (void)keyboardWillShow:(NSNotification *)notification {
CGFloat animDuration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue];
CGRect rect = [self.currentTextField superview].frame;
[UIView animateWithDuration:animDuration animations:^{
[self.scrollView scrollRectToVisible:rect animated:NO];
}];
}
- (void)keyboardWillHide:(NSNotification *)notification {
CGFloat animDuration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue];
CGRect rect = [self.currentTextField superview].frame;
[UIView animateWithDuration:animDuration animations:^{
[self.scrollView scrollRectToVisible:rect animated:NO];
}];
}
的Bug,该文本框的所有边境闪烁我的自定义文本框的边界。但如果我只是滚动scrollView不闪烁
为什么你需要使用'[UIView的animateWithDuration:animDuration动画: [se lf.scrollView scrollRectToVisible:rect animated:NO]; }];',为什么不使用'[self.scrollView scrollRectToVisible:rect animated:NO];'直接 – childrenOurFuture
@childrenOurFuture是正确的,尝试在没有UiView动画的情况下滚动,但是动画:YES – DoN1cK
首先当键盘显示或隐藏,我需要使用键盘动画持续时间相应地滚动scrollView。 –