ios毛玻璃效果

方法一:支持所有ios系统版本:

- (void)setupBlurView

{

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;

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实现的

ios毛玻璃效果

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

}

效果图:

ios毛玻璃效果

上一篇:Java读写文件方法总结


下一篇:Oracle Undo和Redo的关系,区别及相关查询