UITabbar Tab更改动画在转换时显示黑色故障

时间:2015-11-17 06:29:54

标签: ios objective-c animation uitabbar catransition

我正在使用UITabBarController,其中我在用户切换选项卡时添加了转换,并且它在iOS 8中工作正常但在iOS 9中它在转换时显示黑色。

以下是我现在正在使用的代码。

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {

    NSInteger destinationViewControllerIndex = [self.viewControllers indexOfObject:viewController];

    if ([self selectedIndex]==destinationViewControllerIndex) {
        // If Source and Destination Controller both are same return YES
        return YES;
    }
    // Push Animation when tabbar change
    CATransition *animation = [CATransition animation];
    [animation setType:kCATransitionPush];
    if ([self selectedIndex]>destinationViewControllerIndex) {
        [animation setSubtype:kCATransitionFromLeft];
    }else{
        [animation setSubtype:kCATransitionFromRight];
    }
    [animation setDuration:0.35];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                              kCAMediaTimingFunctionEaseIn]];
    [self.view.window.layer addAnimation:animation forKey:@"fadeTransition"];

    return YES;
}

It's look like this when user switch the tabs

1 个答案:

答案 0 :(得分:1)

我在iOS 9中看到了与此非常相似的一些自定义过渡动画。

最后,解决方案是在UITabBar对象上禁用半透明(self.tabBar.translucent = NO;)。