iOS 自定义UITabbar添加系统毛玻璃效果

寿子轩
2023-12-01
    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;//替换掉原生毛玻璃图层

 

 类似资料: