如何设置我的视图大小调整动画?

时间:2010-09-14 23:07:24

标签: iphone objective-c cocoa-touch animation uianimation

我正在调整表格headerView的大小。我想给它制作动画,但我不确定如何。

-(void)layoutForBanner
{
    // Depending on if the banner has been loaded, we adjust the content frame and banner location
    // to accomodate the ad being on or off screen.
    // This layout is for an ad at the bottom of the view.
    if(banner.bannerLoaded)
    {
        headerView.frame = CGRectMake(0, 0, 320, 94);
    }
    else
    {
        headerView.frame = CGRectMake(0, 0, 320, 50);
    }   

    [self.tableView setTableHeaderView:headerView];

}

1 个答案:

答案 0 :(得分:11)

这应该可以解决问题。

[UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.5];
    headerView.frame = CGRectMake(0, 0, 320, 50);
    [UIView commitAnimations];