iOS中的毛玻璃效果

  1. UIVisualEffectView, iOS8之后提供的专门作毛玻璃效果的类 UIVisualEffectView使用以下所示, 只须要在须要实现模糊效果的view上面蒙上一层UIVisualEffectView对象便可. **注意:**只能在iOS8之后才能使用这个类
/    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
//    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    [self.view addSubview:effectView];
    effectView.frame = imageView.frame;
    effectView.alpha = 0.98;
    
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    btn.frame = CGRectMake(10, 50, 100, 40);
    [btn setTitle:@"btn" forState:UIControlStateNormal];
    [effectView.contentView addSubview:btn];

代码效果:git

iOS8之后 能够使用UIVisualEffectView制做毛玻璃效果, 性能也是很是高的, iOS7时候能够使用下面的一个框架, 很简单的框架爱. https://github.com/justinmfischer/7blurgithub

相关文章
相关标签/搜索