我有UITextField和UIView动画,用文本字段显示和隐藏容器。如果我编辑文本然后隐藏我的文本字段,我会看到该文本立即在零位置更改帧,然后在正常位置设置动画。
但它只在第一次隐藏时发生,并且只有在某些文本输入时才会发生。我会对任何想法感激不尽!
有show \ hide动作代码:
- (IBAction)showOrHideSearchBar:(UIButton *)sender {
sender.selected = !sender.selected;
if (sender.selected) {
self.searchBarTopConstraint.constant = self.searchBarContainerView.frame.size.height;
[self.searchTextField becomeFirstResponder];
}
else {
self.searchBarTopConstraint.constant = 0;
[self.searchTextField endEditing:YES];
}
[UIView animateWithDuration:SEARCH_BAR_ANIMATION_DURATION animations:^{
[self.searchBarContainerView layoutIfNeeded];
}];
}