在我的viewDidLoad方法中,我在屏幕左边放置了一个按钮。UIView中的setFrame动画不会移动,只会捕捉到位
然后我用这两个方法来制作动画:
-(void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self showButton];
}
而且方法:
-(void) showButton {
[myButton setTitle:[self getButtonTitle] forState:UIControlStateNormal];
// animate in
[UIView beginAnimations:@"button_in" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDone)];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationBeginsFromCurrentState:YES];
[myButton setFrame:kMyButtonFrameCenter]; // defined CGRect
[UIView commitAnimations];
}
该按钮会立即出现,并没有动画。此外,animationDone选择器立即被调用。
为什么它没有动画我的按钮进入屏幕?
编辑:这有可能有事情做与努力,而在viewDidAppear ...
奇怪的是,如果我稍等一下,动画将起作用。 – TigerCoding