我正在尝试对a进行动画处理,UIImage
这是UIView
界面生成器中a的子视图。我的问题是,该动画会“通过”另一个视图(即表格视图),然后仅“落后于”它,而无法完全显示。我的视图层次结构是这样的:
View
View
SubviewToAnimate
TableView
我已经[self.view bringViewToFront:SubviewToAnimate]
在视图本身和动画中尝试了Both。
动画代码:
-(void)startAnimationWithImageView:(UIImageView*)imageView{
imageViewToMove = imageView;
imageViewFirstAlpha = imageViewToMove.alpha;
firstCenterOfView = imageViewToMove.center;
double firstX =self.parabelWidth*self.startValue;
double firstY = self.parabelHeight*pow(self.startValue, 2);
firstPointOfParabel = CGPointMake(firstX, firstY);
if (points) {
points = nil;
}
points =[[NSMutableArray alloc]init];
for (int counter = self.startValue; counter < self.stopValue; counter++) {
double y = self.parabelHeight*pow(counter, 2);
double x = self.parabelWidth*counter;
CGPoint point = CGPointMake(x, y);
[points addObject:[NSValue valueWithCGPoint:point]];
//DLog(@"point: %@", NSStringFromCGPoint(point));
}
animationCounter = 0;
[self moveView];
}
-(void)moveView{
if (animationCounter < points.count) {
[UIView animateWithDuration:self.duration
delay:0
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationCurveLinear
animations:^{
NSValue *val = [points objectAtIndex:animationCounter];
CGPoint point = [val CGPointValue];
double delta = 1.0/points.count;
imageViewToMove.center = CGPointMake(firstCenterOfView.x-firstPointOfParabel.x+point.x, firstCenterOfView.y-firstPointOfParabel.y+point.y);
imageViewToMove.alpha = sqrt(imageViewToMove.alpha-delta);
double scale = animationCounter*delta;
imageViewToMove.transform = CGAffineTransformMakeScale(sqrt(1-scale), sqrt(1-scale));
animationCounter++;
}
completion:^(BOOL finished){
[self moveView];
}];
}else if (animationCounter == points.count) {
imageViewToMove.center = firstCenterOfView;
imageViewToMove.transform = CGAffineTransformMakeScale(1.0, 1.0);
[UIView animateWithDuration:0.3
delay:0
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationCurveEaseIn
animations:^{
imageViewToMove.alpha = imageViewFirstAlpha;
}
completion:NULL];
}else
return;
}
您不能使用[self.view bringViewToFront:SubviewToAnimate]
将图像视图放在表格视图之上,因为它不是表格视图的同级。
如果你有...
View
SubView
ImageView (animated view)
TableView
然后该代码将起作用。
或者,在您当前的层次结构中,您可以将SubView置于最前面,这将使图像视图随之出现。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句