开发者

How can I hide navigation bar through CAAnimation?

Actually For show/hide I am using UIView Animation. And Simple methods like animated : YES/NO. But it does not give me smooth response.. Please give me suggestions...

BOOL navBar开发者_如何学编程State = [self.navigationController isNavigationBarHidden];


    [UIView beginAnimations:nil context:NULL];

    [UIView setAnimationDuration:0.3];


    [self.navigationController setNavigationBarHidden:!navBarState animated:NO];


    [UIView commitAnimations];

It is not giving me satisfactory result I want to do the same thing with CAAnimation..


Why do you need to place the following line into UIView animation braces:

[self.navigationController setNavigationBarHidden:!navBarState animated:NO];

Why not just call it with animated:YES without calls to [UIView beginAnimation]/[UIView commitAnimation]?

[self.navigationController setNavigationBarHidden:!navBarState animated:YES];


CGRect rect = self.navigationController.navigationBar.frame;
    rect.origin.y = rect.origin.y < 0 ?
    rect.origin.y + rect.size.height
    :   rect.origin.y + rect.size.height;

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.2];
    self.navigationController.navigationBar.frame = rect;
    [UIView commitAnimations];

Just use above code which may help you to get smooth animation...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜