毛玻璃效果

来源:互联网 发布:js 命名空间 编辑:程序博客网 时间:2024/05/22 14:07


        // blur effect        float sysVer = [[[UIDevice currentDevice] systemVersion] floatValue];#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0        if (sysVer >= 8.0)        {            [self blurEffectView];        }        else        {            [self blurEffectViewBefore8];        }        #else        [self blurEffiteViewBefore8];#endif/** iOS 8之前版本 */- (void)blurEffectViewBefore8{    UIToolbar *toolBar = [[UIToolbar alloc] init];    toolBar.barStyle = UIBarStyleBlackTranslucent;        [_topImgView addSubview:toolBar];        [toolBar mas_makeConstraints:^(MASConstraintMaker *make) {        make.edges.equalTo(_topImgView);    }];}/** iOS 8之后版本 */- (void)blurEffectView{    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];        [_topImgView addSubview:effectView];        [effectView mas_makeConstraints:^(MASConstraintMaker *make) {        make.edges.equalTo(_topImgView);    }];}


备注:

__IPHONE_OS_VERSION_MAX_ALLOWED 值取决于SDK版本

__IPHONE_OS_VERSION_MIN_REQUIRED 值取决于工程的Deployment Target

 












原创粉丝点击