带有模糊TableView Scroll Offset的透明导航栏

时间:2016-03-10 09:56:54

标签: ios objective-c uitableview

我正在努力创造这种效果。

仅对滚动偏移视图

模糊效果

enter image description here

我尝试以编程方式执行此操作

- (void)addBlurEffect {
    // Add blur view
    //    CGRect statusBarViewRect = [[UIApplication sharedApplication] statusBarFrame];
    CGRect bounds = self.bounds;

    /*to extwnd from status bar till the end of navigation bar height*/
    CGRect aRect = CGRectMake(0, self.frame.origin.y-40, self.frame.size.width, bounds.size.height+20);

    /*Make a blur view*/
    UIVisualEffectView *visualView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];

    /*Assign a tag to make it accessable from view hirarchy*/
    visualView.tag = 10000;

    visualView.frame = aRect;
    visualView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    [self addSubview:visualView];
    self.backgroundColor = [UIColor colorWithRed:42.0f green:152.0f blue:231.0f alpha:0.7f];
    [self sendSubviewToBack:visualView];

    /*back button was disabled following enables it*/
    visualView.userInteractionEnabled = false;
} 

我无法重新创建用户界面。这就是我得到的 UIEffectView adds a gradient effect.

渐变效果,而不是清晰的视图。我该如何重新创建所需的UI效果?

2 个答案:

答案 0 :(得分:0)

尝试这个: - self.tableView.contentInset = UIEdgeInsetsMake(44,1,0,0);

答案 1 :(得分:0)

使用此功能添加模糊效果进行查看。

var blurEffectView:UIVisualEffectView!

func addblurEffectToView()
    {
        let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
        blurEffectView = UIVisualEffectView(effect: blurEffect)
        blurEffectView.frame = view.bounds
        blurEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] // for supporting device rotation
        blurEffectView.alpha = 1
        view.addSubview(blurEffectView)
    }