iOS 实现毛玻璃效果


毛玻璃 的UI 设计在手机开发中已经 非常热门,在之前的 开发中 一般用到 github上FXBlurView 封装好的一个view类 ,可以直接应用加载到控件中,iOS 8 后更新的   UIBlurEffect 类和  UIVisualEffectView 类使这种特效应用更加便捷,高效。
使用也非常简便, UIBlurEffect 类是设定毛玻璃特效的类型, UIVisualEffectView 类在创建时加入上一个类对象,剩下的跟普通的view 控件等用法就一样了 ,附代码事例:

   //  创建需要的毛玻璃特效类型

    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];

    //  毛玻璃view 视图

    UIVisualEffectView *effectView = [[UIVisualEffectView allocinitWithEffect:blurEffect];

    //添加到要有毛玻璃特效的控件中

    effectView.frame = self.imageV.bounds;

    [self.imageV addSubview:effectView];

    //设置模糊透明度

    effectView.alpha = .8f;

如果要用到github上的FXBlurView ,它的下载路径:https://github.com/nicklockwood/FXBlurView .

猜你喜欢

转载自blog.csdn.net/sevenquan/article/details/52624365