UITabView頁面切換效果實現
阿新 • • 發佈:2019-01-26
方法一:
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { NSUInteger controllerIndex = item.tag; UIView * fromView = self.selectedViewController.view; UIView * toView = [[self.viewControllers objectAtIndex:controllerIndex] view]; // Transition using a page curl. [UIView transitionFromView:fromView toView:toView duration:0.5 options:(controllerIndex > self.selectedIndex ? UIViewAnimationOptionTransitionCurlUp : UIViewAnimationOptionTransitionCurlDown) completion:^(BOOL finished) { if (finished) { self.selectedIndex = controllerIndex; } }]; }
方法二:
-(void)tabBar:(UITabBar*)atabBar didSelectItem:(UITabBarItem*)item { CATransition* animation = [CATransition animation]; [animation setDuration:0.5f]; [animation setType:kCATransitionFade]; [animation setSubtype:kCATransitionFromRight]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]; [[self.view layer]addAnimation:animation forKey:@"switchView"]; }