如果有人能帮我找到解决下一个问题的办法,我将不胜感激。
我想动画一个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属性,根本没有成功。
我已经想明白了。
我的问题是,我有UIBUttons代替,所以我把它们放在uiview和设置一个更大的zposition到第二个视图和背景颜色必须是一个从父视图。