2012-09-10 59 views
0

我有一個觀點我已經拖多一個視圖,並分配有如何當UIView的是隱藏在sameView

動畫的UIView UIView的IBOutlet中* popupIpadView其中包含的tableview文本框和其他按鈕。

我的要求是,在加載時,popupIpadView將在最初隱藏。當我點擊一個按鈕時,將出現這個PopupIpadview。但是我希望這個視圖出現在從左到右的動畫過渡中,反之亦然。我怎樣才能做到這一點?

例如,我使用下面的代碼,但沒有任何反應。

- (IBAction)showPopover:(UIButton *)sender 
{ 
    popupiPhoneView.hidden = NO; 
    popupiPhoneView.backgroundColor = [UIColor colorWithWhite:0 alpha:.5];   

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationCurve:UIViewAnimationCurveLinear]; 
    [UIView setAnimationDuration:3.0]; 
    [UIView commitAnimations]; 
} 

回答

1

代替使用隱藏屬性的,設置alpha值設置爲0和原點到左側出來的可見屏幕,說-320 x和0收率

在您的動畫塊中,將alpha設置爲1,同時傳遞適當的過渡樣式。 最初設置您的視圖

yourview.alpha = 0; 
yourview.x = -320; 

然後將其設置爲在過渡代碼適當的座標。

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:1.0]; 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES]; 

yourview.alpha = 1; 
yourview.x = 320; // new coordinates 
[UIView commitAnimations];