码迷,mamicode.com
首页 > 移动开发 > 详细

ios毛玻璃效果

时间:2016-09-28 19:02:48      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

方法一:支持所有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实现的

技术分享

- (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毛玻璃效果

标签:

原文地址:http://www.cnblogs.com/haohao-developer/p/5917467.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!