iOS开发-毛玻璃效果

   直接上代码!!!!!!

 

 

  

UIImageView *backImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    backImageView.image = [UIImage imageNamed:@"picture.jpg"];
    [self.view addSubview:backImageView];
    
    /**
     *  UIBlurEffect  它的模糊对象适用于UIVisualEffectView, 只有一个类方法.
     *  Style有三种:  UIBlurEffectStyleExtraLight  (与模糊对象相比色相更亮)
     *               UIBlurEffectStyleLight  (与模糊对象色相一样)
     *               UIBlurEffectStyleDark  (与模糊对象相比色相变暗)
     */
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    
    
    /**
     *  UIVisualEffectView对象提供了一种简单的方法实现一些复杂的视觉效果。根据预期的效果,效果可能会影响后面的内容分层视图或视图的contentView内容添加到视觉效果。
     *  它有两个属性: contentView 和 effect
     *  如果把UIBlurEffect的对象放到contentView则不会影响UIVisualEffectView后面的内容分层视图或视图的觉效果。
     */
    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    
    //调整alpha的值,改变模糊程度
    effectView.alpha = 1.0;
    effectView.frame = backImageView.bounds;
    [backImageView addSubview:effectView];

 

                                   原图                                                                        效果图

                               

posted @ 2016-04-01 14:29  小_蜗_牛  阅读(138)  评论(0编辑  收藏  举报