Ios 带模糊的UITabBar-故事板

Ios 带模糊的UITabBar-故事板,ios,objective-c,uitabbarcontroller,uitabbar,Ios,Objective C,Uitabbarcontroller,Uitabbar,使用情节串连板时,如何在UITabBarController上实现模糊效果? 这就是它现在的样子 试试这个。这会使你的酒吧变成半透明的,这就是你得到想要的东西的方式。好吧,你必须创建一个带有自定义背景的自定义UITabBar 有些东西与此相关: @implementation MyTabBar - (void)awakeFromNib { [super awakeFromNib]; self.backgroundColor = [UIColor clearColor];

使用情节串连板时,如何在UITabBarController上实现模糊效果?

这就是它现在的样子


试试这个。这会使你的酒吧变成半透明的,这就是你得到想要的东西的方式。

好吧,你必须创建一个带有自定义背景的自定义UITabBar

有些东西与此相关:

@implementation MyTabBar

- (void)awakeFromNib
{
    [super awakeFromNib];

    self.backgroundColor = [UIColor clearColor];
    [self setBackgroundImage:[UIImage imageNamed:@"transparent"]];

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.bounds];
    [self addSubview:imageView];

    // If you want to show static blured image, then just cut it from your psd and set to imageView
    // imageView.image = [UIImage imageNamed:@"static_blured_bg"];

    // If you want to show dynamic blur, that will blur everything behind it, then you must
    // 1. make a screenshot of viewController's view that is currently showing.
    // 2. crop it with frame of tab bar.
    // 3. make it blur
    // 4. set it to image view.
    // And finally, for make it dynamic, you mast repeat stepst 1-4 every time when layout changes. (e.g. you can make a timer with 0.3 secs of tick, or something else).

    // Or, you can use https://github.com/nicklockwood/FXBlurView for dynamic blurring.
    // Choose yourself :)
}

@end
别忘了将类设置为UITabBarController的选项卡栏,从情节提要设置为“MyTabBar”

如果您决定制作自己的动态模糊,那么这将对您有用

苹果UIImage上的类别。


对tabBarController进行子类化,并将其粘贴到viewDidLoad中:

[[UITabBar appearance] setBackgroundImage:[UIImage new]];
UIToolbar* blurredView = [[UIToolbar alloc] initWithFrame:self.tabBar.bounds];
[blurredView setBarStyle:UIBarStyleBlack];
[self.tabBar insertSubview:blurredView atIndex:0];
-(BOOL)应用程序中:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项
,为背景图像和阴影图像设置清晰图像。然后将新的UIVisualEffectView和颜色遮罩视图作为其第一个子视图插入tabbar

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];

您现在可以添加选项卡栏控制器的屏幕截图吗?因为默认情况下,UITabBarController的条会模糊它后面的所有内容。@arturdev,更新了question@l0gg3r你的态度怎么样?!要了解模糊效果的含义,请按照您的建议在google中查找。为什么故事板对你来说毫无意义?你不能完全控制公共API中的模糊,你只能在明暗两种外观之间进行选择,并有选择地对其应用条形色调。如果你想做一些不同的事情,你可以自己做。>在iOS 7上,默认情况下选项卡栏是半透明的。此外,系统模糊应用于所有选项卡栏。这允许您的内容显示在工具栏下方。如果您想在选项卡栏中自定义模糊,这是正确的答案。但是,现在您需要将掩码添加到blurView的contentView,否则应用程序将崩溃。[blurView.contentView addSubview:maskView];
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];