ios - Animation does not origin from where I want it to? Why? -
i'm doing countdown clock game. want numbers animated come middle of screen , fade away in middle. when run code come right bottom of screen instead of specified (160,284). problem be?
} else if (startgameeveryint == 3) { uiimageview *object = [[uiimageview alloc] initwithframe:cgrectmake(160,284,280 ,280)]; [object setimage:[uiimage imagenamed:@"1.png"]]; [self.view addsubview:object]; [uiview animatewithduration:1 animations:^{ object.alpha = 0; object.frame = cgrectmake(160, 284, 50, 50); } completion:^(bool finished){ startgameeveryint = 0; [startgametimer invalidate]; startgametimer = nil; [self startit]; (uiview *view in self.view.subviews) { if (view.tag > 10) { [view removefromsuperview]; } } }]; }
if change cgrect settings before animation-
cgrectmake((self.view.frame.size.width-160)/2, (self.view.frame.size.height-284)/2, 160, 284)
then changing size of object did before to
cgrectmake((self.view.frame.size.width-50)/2, (self.view.frame.size.height-50)/2, 50, 50)
this should work in middle of screen. x, y positions of cgrect put top lhs points of object position. why object looked off bottom right.
i hope helps
cheers, jim
Comments
Post a Comment