我试图在界面构建器中设置UIImage
的动画,这是UIView
的子视图。
我的问题是,这个动画是"通过"另一种观点是表格视图,然后它简单地落后于#34;它并没有显示出来。
我的视图层次结构如下:
View
View
SubviewToAnimate
TableView
我试过[self.view bringViewToFront:SubviewToAnimate]
在视图本身和动画中。
动画代码:
-(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;
}
答案 0 :(得分:2)
您无法使用[self.view bringViewToFront:SubviewToAnimate]
将图片视图放在表格视图的顶部,因为它不是表格视图的兄弟。
如果你有......
View
SubView
ImageView (animated view)
TableView
然后该代码将起作用。
或者,在您当前的层次结构中,您可以将SubView带到前面,这将带来图像视图。