第一種
CATransition *transition = [CATransition animation]; transition.duration = 0.4f;//時間 transition.type = kCATransitionPush;//動畫的效果 transition.subtype = kCATransitionFromBottom;//動畫的目的地 [self.view addSubview:_backGroundView];//這是是自己要做的事情一般是添加一個View 這個需要自己寫 [self.view.layer addAnimation:transition forKey:@"animation"];
[UIView beginAnimations:@"animation" context:nil]; [UIView setAnimationDuration:2.0f];//時間 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//效果 [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES]; [self.view addSubview:_backGroundView];//要做的事情 [UIView commitAnimations];
[UIView animateWithDuration:1.0 animations:^{ _backGroundView.frame = CGRectMake(0, originY, _screenSize.width, 0);//要達到的狀態值 }completion:^(BOOL finished){ [_backGroundView removeFromSuperview]; }];