使用 Storyboard 时如何在 UITabBarController 上实现模糊效果?
这就是现在的样子
最佳答案
在 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
中,为 backgroundImage 和 shadowImage 设置清晰图像。然后将新的 UIVisualEffectView 和颜色 mask View 作为第一个 subview 插入到标签栏。
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UITabBar *tabBar = tabBarController.tabBar;
[[UITabBar appearance] setBackgroundImage:[UIImage new]];
[[UITabBar appearance] setShadowImage:[UIImage new]];
UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, tabBar.bounds.size.height)];
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
[blurView setEffect:blurEffect];
UIView *maskView = [[UIView alloc] initWithFrame:blurView.frame];
maskView.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.5];
[blurView addSubview:maskView];
[tabBar insertSubview:blurView atIndex:0];
关于ios - 带模糊的 UITabBar - Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24670511/