ios - 带模糊的 UITabBar - Storyboard

标签 ios objective-c uitabbarcontroller uitabbar

使用 Storyboard 时如何在 UITabBarController 上实现模糊效果? enter image description here

这就是现在的样子 enter image description here

最佳答案

-(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/

相关文章:

ios - 带标签栏 Controller 的导航 Controller ?

ios - 使用自动增量 Swift 3 在 Firebase 数据库中存储帖子(图像、标题)

objective-c - '无法对类型 : (null)' when setting up UINavigationController 进行比较查询

iphone - 有没有一种巧妙的方法来判断 iPhone/iPad 是否已被用户设置密码

ios - 使用 MPMoviePlayerController 禁用 AirPlay

ios - AFNetworking 可以很容易地返回一个 UIImage,但是我如何返回 NSData?

ios - UIImageView图像出现两次

iphone - 将导航 Controller 添加到选项卡栏应用程序(以编程方式)

ios - 将视频播放器添加到 UITableView Cell *Swift

ios - TabBarController 按标题选择?