2014-03-03 21 views

回答

0
[UIView animateWithDuration:1.0 animations:^{ 
    //here change position and alpha 
    CGRect newFrame = view.frame; 
    newFrame.origin.y += 50; 
    view.frame = newFrame; 
    view.alpha = 1.0; 
} completion:^(BOOL finished) { 
    //called when animation did finish. do what you want 
}]; 
+0

不要在動畫中將動畫alpha和動畫的0和1都設置爲動畫。它應該在動畫之前爲0。只需在動畫中將其設置爲1即可。 – rmaddy

+0

@rmaddy對不起,我的意思是在開始動畫之前將alpha設置爲0)=) –

0

https://developer.apple.com/library/ios/documentation/windowsviews/conceptual/viewpg_iphoneos/animatingviews/animatingviews.html

關於動畫的一切。 沒關係。

//something similar to what you want: 

- (IBAction)showHideView:(id)sender 
{ 
    // Fade out the view right away 
    [UIView animateWithDuration:1.0 
     delay: 0.0 
     options: UIViewAnimationOptionCurveEaseIn 
     animations:^{ 
      thirdView.alpha = 0.0; 
     } 
     completion:^(BOOL finished){ 
      // Wait one second and then fade in the view 
      [UIView animateWithDuration:1.0 
       delay: 1.0 
       options:UIViewAnimationOptionCurveEaseOut 
       animations:^{ 
        thirdView.alpha = 1.0; 
       } 
       completion:nil]; 
     }]; 
} 
0

像這樣的事情會做的伎倆:

UIView *box = [[UIView alloc] initWithFrame:CGRectMake(self.view.center.x, self.view.center.y, 100, 50)]; 
box.backgroundColor = [UIColor blackColor]; 
box.alpha = 0.0f; 
[self.view addSubview:box]; 


[UIView animateWithDuration:2.0f 
       animations:^{ 
        box.alpha = 1.0f; 
        CGRect frame = CGRectMake(self.view.center.x, self.view.center.y - 100, 100, 50); 
        [box setFrame:frame]; 
       }]; 
相關問題