ios毛玻璃效果

方法一:支持全部ios系統版本:ios

- (void)setupBlurViewapi

{blog

    UIImageView *darkView = [[UIImageView alloc] init];it

    darkView.frame = self.view.bounds;io

    UIImage *image = [UIImage imageWithData:_hotModel.picData];ios8

    darkView.image = image;方法

    darkView.backgroundColor = [UIColor clearColor];im

    [self.view addSubview:darkView];img

    _darkView = darkView;view

 

    UIToolbar *toolBar = [[UIToolbar alloc] init];

    [toolBar setBarStyle:UIBarStyleBlack];

    [darkView addSubview:toolBar];

    toolBar.translatesAutoresizingMaskIntoConstraints = NO;

    [toolBar mas_makeConstraints:^(MASConstraintMaker *make) {

        make.edges.equalTo(darkView);

    }];

}

 

方法二:只能在ios8.0以上纔有效果,利用系統的api實現的

- (void)addEffectView{

    UIImageView *darkView = [[UIImageView alloc] init];

    darkView.frame = self.view.bounds;

    UIImage *image = [UIImage imageWithData:_hotModel.picData];

    darkView.image = image;

    darkView.backgroundColor = [UIColor clearColor];

    [self.view addSubview:darkView];

    _darkView = darkView;

    

    UIBlurEffect *dark = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];

    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:dark];

    effectView.frame = self.view.bounds;

    [darkView addSubview:effectView];

}

 

效果圖:

相關文章
相關標籤/搜索