1
动画UIViews有两种主要的记录方法。一个是不推荐的过程,其中一个以方法beginAnimations:context:
开始多个调用,而另一个较新的建议方法是基于块的。UIViewAnimation:基于阻止的不工作。弃用风格的作品?
我在我的应用程序中有以下代码。但是,只有较旧的弃用动画片段才适用。较新的基于块的方法第一次工作,但随后的每一次都直接跳到动画的结尾,并立即向我显示最后一帧。有没有人有过这方面的经验?
-(void)updateImageViewSlider:(UIImage *)image {
mImageFeedSwipe.alpha = 0.0;
[mImageFeedSwipe setHidden:NO];
mImageFeedSwipe.frame = DEFAULT_IMAGEVIEW_RECT;
[mImageFeedSwipe setImage:image];
//
// The following animation code works fine.
//
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
mImageFeedSwipe.alpha = 1.0;
[mImageFeedSwipe setFrame:NEW_IMAGEVIEW_RECT];
[UIView commitAnimations];
//
// The following DOES NOT work except on the first run
//
int animationOptions = 0
| UIViewAnimationOptionCurveEaseInOut
| UIViewAnimationOptionBeginFromCurrentState
| UIViewAnimationOptionAllowUserInteraction;
[UIView animateWithDuration:1.0
delay:0
options:animationOptions
animations:^{
// Bring in the swiping image view...
mImageFeedSwipe.alpha = 1.0;
[mImageFeedSwipe setFrame:NEW_IMAGEVIEW_RECT];
}
completion:nil];
}
这是通过[self performSelectorOnMainThread...]
在主线程上运行。