2013-03-18 79 views
0

我很感謝有人能幫助我找到解決下一種情況的方案。動畫視圖的框架重定位與另一個視圖重疊

我想動畫的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]; 

我一直在玩z位置,不透明,不透明度,透明度和bringToFront性質沒有成功可言。

回答

0

我已經想通了。

我的問題是我有UIBUttons,所以我把它們放在UIViews中,並設置一個更大的zposition到第二個視圖,並且背景顏色必須是來自超級視圖的顏色。