0

搜索栏使用以下代码进行动画处理:

- (IBAction)toggleSearchBar:(UIBarButtonItem *)sender{

CATransition *applicationLoadViewIn = [CATransition animation];
[applicationLoadViewIn setDuration:0.2];
[applicationLoadViewIn setType:kCATransitionPush];
[applicationLoadViewIn setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];

if (self.searchBar.hidden) {

    self.searchBar.hidden = NO;
    [self.searchBar becomeFirstResponder];

    [applicationLoadViewIn setSubtype:kCATransitionFromBottom];
    [[searchBar layer] addAnimation:applicationLoadViewIn forKey:kCATransitionPush];

}else{

    self.searchBar.hidden = YES;
    [self.searchBar resignFirstResponder];

    [applicationLoadViewIn setSubtype:kCATransitionFromTop];
    [[searchBar layer] addAnimation:applicationLoadViewIn forKey:kCATransitionPush];

}
}

它工作正常,除了动画第一次运行时的滞后。有没有办法修复它?任何帮助将不胜感激:)

编辑 1

他 leftBarButton 被连接到toggleSearchBar:行动。应用程序已加载。第一个动画是 leftBarButton 第一次点击。

4

1 回答 1

0

为什么不在加载视图控制器时将其显示在屏幕外……这有点笨拙,但它应该可以解决问题。

于 2012-09-25T21:55:09.010 回答