如果有人可以帮助我找到下一种情况的解决方案,我将不胜感激。
我想将 UIView 的重新定位动画化到一个点到另一个点(我能够做到这一点,请检查下面的代码),但我在中间有另一个 UIView .. 事实上,第二个视图位于视图之后我想搬家。我想要完成的基本上是避免在第二个视图上看到动画。
//second view placed at position x = 100, width = 20, height = 20
UIView *secondView = [[UIView alloc] initWithFrame:CGRectMake(100, 0, 20, 20)];
seconView.backgroundColor = [UIColor redColor];
[self.superview addSubview:secondView];
//from now on, this code occurs when tapping a button
//main view placed at position x = 0, width = 100, height = 20
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 20)];
view.backgroundColor = [UIColor yellowColor];
[self.superview addSubview:view];
[UIView beginAnimations:@"moveView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.7f];
//main view will be moved to position x = 120, meaning that it will go through the second view.
subView.frame = CGRectOffset(view.frame, view.frame.size.width + seconView.frame.size.width, 0);
[UIView commitAnimations];
我一直在玩 zposition、opaque、opacity、alpha 和 BringToFront 属性,但完全没有成功。