如果有人能帮我找到下一个情况的解决方案,我感激不尽。
我想要将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属性,但根本没有成功。
答案 0 :(得分:0)
我已经明白了。
我的问题是我有UIBUttons,所以我将它们放在UIViews中并为第二个视图设置一个更大的zposition,背景颜色也必须是superview中的颜色。