iOS 8使用UIBlurEffect实现毛玻璃特效

2019/7/9 22:41:16

本文主要是介绍iOS 8使用UIBlurEffect实现毛玻璃特效,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

iOS 8 后使用UIBlurEffect 类和UIVisualEffectView 类添加毛玻璃特效更加便捷,高效。

//创建ImageView
IImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"5"]];
  // 创建需要的毛玻璃特效类型
  /**
   * UIBlurEffectStyleExtraLight,
   * UIBlurEffectStyleLight,
   * UIBlurEffectStyleDark
   */
  UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];

  //添加到要有毛玻璃特效的控件中
  UIVisualEffectView *visual = [[UIVisualEffectView alloc] initWithEffect:blur];
  visual.frame = imageView.bounds;
  [self.view addSubview:imageView];

效果图:

原图:

(1) UIBlurEffectStyleExtraLight

(2) UIBlurEffectStyleLight

(3) UIBlurEffectStyleDark

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持找一找教程网。



这篇关于iOS 8使用UIBlurEffect实现毛玻璃特效的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程