【问题标题】:iOS:Help Blur screen on the top of home viewiOS:帮助在主视图顶部模糊屏幕
【发布时间】:2015-01-20 07:48:45
【问题描述】:

我的应用程序需要在主视图控制器之上提供帮助。我已将标签栏控制器作为根视图控制器并添加了导航视图控制器。因此在第一个屏幕的外观中,标签栏和导航栏与视图主体一起出现.当我尝试通过 pageviewcontroller 示例放置帮助屏幕时,视图确实加载到第一个屏幕选项卡视图中,并且导航栏位于前面,保持页面视图控制器返回。我尝试过

   [self addChildViewController:walkthrough];
   [self.view addSubview:walkthrough.view];
   [self.tabBarController.view bringSubviewToFront:walkthrough.view];

请帮助如何获得页面视图屏幕前面。有没有示例教程请帮助我 注意:botn导航栏和tabbar不应该隐藏

【问题讨论】:

    标签: ios objective-c uitabbarcontroller uinavigationbar


    【解决方案1】:

    这就是我在我的应用程序中为演练所做的。你可以从这里下载这个 FXBlurView 库: https://github.com/nicklockwood/FXBlurView

    在我的 .h 文件中

    #import "FXBlurView.h"
    IBOutlet UIView *viewWalkThrough;
    FXBlurView *overlayView;
    

    在我的 .m 文件中

    #define SYSTEM_SCREEN_SIZE [[UIScreen mainScreen] bounds].size
    #define kProfileWalkthrough  @"ProfileWalkthrough"
    
    if (![[[NSUserDefaults standardUserDefaults] valueForKey:kProfileWalkthrough] boolValue]) {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kProfileWalkthrough];
        [[NSUserDefaults standardUserDefaults] synchronize];
    
        overlayView = [[FXBlurView alloc] initWithFrame:CGRectMake(0, 0, SYSTEM_SCREEN_SIZE.width, SYSTEM_SCREEN_SIZE.height)];
        [overlayView setDynamic:YES];
        [overlayView setBlurRadius:5.0f];
        [overlayView setBlurEnabled:YES];
        [overlayView setTintColor:[UIColor blackColor]];
        [self.view.window addSubview:overlayView];
        [self displayOverlay:viewWalkThrough aboveView:self.view.window];
    
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeWalkThrough:)];
        [viewWalkThrough addGestureRecognizer:tapGesture];
    }
    
    - (void)closeWalkThrough:(UITapGestureRecognizer *)tapRecognizer {
    [overlayView          removeFromSuperview];
    [self.viewWalkThrough removeFromSuperview];
    

    }

    - (void)displayOverlay:(UIView *)subView aboveView:(UIView *)superView {
    subView.translatesAutoresizingMaskIntoConstraints = NO;
    
    [superView addSubview:subView];
    [superView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[subView]|" options:kNilOptions metrics:nil views:NSDictionaryOfVariableBindings(subView)]];
    [superView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[subView]|" options:kNilOptions metrics:nil views:NSDictionaryOfVariableBindings(subView)]];
    
    [superView layoutSubviews];
    

    }

    【讨论】:

    • 我有近 6 个屏幕,它们会像页面视图控制器一样确认,而不是像标签栏和导航栏上方的单个 ui 一样
    • 您可以将该页面视图控制器的视图作为子视图添加到窗口而不是您的主视图控制器。
    猜你喜欢
    • 1970-01-01
    • 2011-07-11
    • 1970-01-01
    • 2016-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多