Sunday, 25 August 2013

Animate frame changes from viewDidLoad

Animate frame changes from viewDidLoad

I want to move my buttons and labels to specific locations when the view
loads. At first everything is in the center and when it loads everything
is supposed to expand to designated locations. I have this but the icons
and labels don't move. It works if I make a button in the same view and
put the code in it though.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
CGRect framehi = homeIcon.frame;
framehi.origin.x = 15;
framehi.origin.y = 70;
CGRect framehl = homeLabel.frame;
framehl.origin.x = -8;
framehl.origin.y = 136;
CGRect framesmi = smediaIcon.frame;
framesmi.origin.x = 131;
framesmi.origin.y = 70;
CGRect framesml = smediaLabel.frame;
framesml.origin.x = 108;
framesml.origin.y = 136;
CGRect framemi = mediaIcon.frame;
framemi.origin.x = 249;
framemi.origin.y = 70;
CGRect frameml = mediaLabel.frame;
frameml.origin.x = 225;
frameml.origin.y = 136;
CGRect frameni = newsIcon.frame;
frameni.origin.x = 15;
frameni.origin.y = 211;
CGRect framenl = newsLabel.frame;
framenl.origin.x = -8;
framenl.origin.y = 277;
CGRect framebi = bullyIcon.frame;
framebi.origin.x = 131;
framebi.origin.y = 211;
CGRect framebl = bullyLabel.frame;
framebl.origin.x = 108;
framebl.origin.y = 277;
CGRect framespi = sportsIcon.frame;
framespi.origin.x = 249;
framespi.origin.y = 211;
CGRect framespl = sportsLabel.frame;
framespl.origin.x = 225;
framespl.origin.y = 277;
CGRect framesti = staffIcon.frame;
framesti.origin.x = 15;
framesti.origin.y = 355;
CGRect framestl = staffLabel.frame;
framestl.origin.x = -8;
framestl.origin.y = 421;
CGRect framehbi = handbookIcon.frame;
framehbi.origin.x = 131;
framehbi.origin.y = 355;
CGRect framehbl = handbookLabel.frame;
framehbl.origin.x = 108;
framehbl.origin.y = 421;
CGRect frameai = aboutIcon.frame;
frameai.origin.x = 249;
frameai.origin.y = 355;
CGRect frameal = aboutLabel.frame;
frameal.origin.x = 225;
frameal.origin.y = 421;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.25];
homeIcon.frame = framehi;
homeLabel.frame = framehl;
smediaIcon.frame = framesmi;
smediaLabel.frame = framesml;
mediaIcon.frame = framemi;
mediaLabel.frame = frameml;
newsIcon.frame = frameni;
newsLabel.frame = framenl;
bullyIcon.frame = framebi;
bullyLabel.frame = framebl;
sportsIcon.frame = framespi;
sportsLabel.frame = framespl;
staffIcon.frame = framesti;
staffLabel.frame = framestl;
handbookIcon.frame = framehbi;
handbookLabel.frame = framehbl;
aboutIcon.frame = frameai;
aboutLabel.frame = frameal;
[UIView commitAnimations];
}

No comments:

Post a Comment