1. 程式人生 > >setAnimationTransition:forView:cache: 運行動畫時背景色問題

setAnimationTransition:forView:cache: 運行動畫時背景色問題

animate uiview orm else eight trend code window mat

首先我描寫敘述一下問題:當我從一個view到另外一個view的時候?

解答:這個問題的解決還須要看setAnimationTransition:forView:cache: 官方Api,官方是這樣說的:

1.Begin an animation block.
2.Set the transition on the container view.
3.Remove the subview from the container view.
4.Add the new subview to the container view.
5.Commit the animation block.

1.開始一個動畫塊。

2.在容器視圖中設置轉換。

3.在容器視圖中移除子視圖。 4.在容器視圖中加入子視圖。

5.結束動畫塊。

就是他全部的操作都是在父View上進行操作的,我的代碼是這樣寫得:

 AppDelegate * delegate = [UIApplication sharedApplication].delegate;
    delegate.nav_Center.view.backgroundColor = [UIColor clearColor];
    //[delegate.window setBackgroundColor:[UIColor whiteColor]];
    [self.navigationController.view superview].backgroundColor = [UIColor whiteColor];
    for (UIViewController * c in delegate.nav_Center.viewControllers) {
        if([c isKindOfClass:[TrendViewController class]]) {
            if (curve>=0) {
                [UIView  beginAnimations: @"PopNav" context: nil];
                [UIView setAnimationCurve: curve];
                [UIView setAnimationDuration:0.75];
                [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
                NSLog(@"===%@=%@",[[self.navigationController.view superview] class],[self.navigationController.view class]);
	            [self.navigationController popViewControllerAnimated:NO];
                [UIView commitAnimations];
            }
            else {
	            [self.navigationController popViewControllerAnimated:YES];
            }
            return YES;
        }
    }

直接設置要切換到view的父view的背景色就ok了。當然了,有時候他的父view也可能是window。

詳細情況詳細分析吧。

希望能幫助一些人。



setAnimationTransition:forView:cache: 運行動畫時背景色問題