iOS 自定義UITabbar新增系統毛玻璃效果
阿新 • • 發佈:2019-02-11
UIImageView *backView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, TabBar_Height_1)]; backView.image = [UIImage imageWithColor:[UIColor colorWithHex:0xffffff alpha:0.5] size:CGSizeMake(SCREEN_WIDTH, TabBar_Height_1)]; UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect]; effectView.frame = CGRectMake(0, 0, SCREEN_WIDTH, TabBar_Height_1); [backView addSubview:effectView]; //這兩句話缺一不可 [rootTabBarController.tabBar insertSubview:backView atIndex:0];//新增到 tabbar 底層 rootTabBarController.tabBar.backgroundImage = backView.image;//替換掉原生毛玻璃圖層