如何为我的视图大小调整添加动画效果?

3

我正在调整表格的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个回答

11

这应该就可以解决问题了。

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接