How can I animate my view resizing?
-
02-10-2019 - |
Question
I am resizing my tables headerView. I want to animate it, but I am not sure how.
-(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];
}
Solution
This should do the trick.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.5];
headerView.frame = CGRectMake(0, 0, 320, 50);
[UIView commitAnimations];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow