下面的函数是一个名为TitleOverlay的类的方法,它是一个带有textView的透明覆盖。
该函数通过设置覆盖的alpha动画来显示覆盖,同时使用动画的animationWillStart属性来显示键盘。
基本上,第一次,有滞后。在随后的所有时间里,键盘和叠加动画并行出现,看起来很不错。
我能做些什么来解决这个问题?
- (void) showOverlay {
[[self superview] bringSubviewToFront:self];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[nc addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
[UIView beginAnimations:nil context: nil];
[UIView setAnimationDuration: .5];
[UIView setAnimationDelegate:titleField];
[UIView setAnimationWillStartSelector:@selector(becomeFirstResponder)];
self.whiteBlock.alpha = 1;
[UIView commitAnimations];
}