【发布时间】:2015-11-17 06:29:54
【问题描述】:
我正在使用 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;
}
【问题讨论】:
-
我遇到了类似的问题,用这种方法解决了,stackoverflow.com/a/64888893/1002338
标签: ios objective-c animation uitabbar catransition