1, UIImage 图片加滤镜,CoreImage(CIImage,iOS6+), Accelerate,GPUImage等
2,iOS7+, 使用view自己的type,用view内部处理。 比如UIToolBar
3,iOS8+, 使用UIVisualEffectView
4,UIStoryboard拖拽UIVisualEffectView的使用方法?
Visual Effect View with Blur
Visual Effect Views with Blur and Vibrancy
这两种view都是UIVisualEffectView,UIVisualEffectView的contentView还可以嵌套一个UIVisualEffectView, 被嵌套的UIVisualEffectView的vibrancy属性不一样。一个是true,另一个是false,它决定了毛玻璃上的view的显示效果。
在代码中,并没有直接设置vibrancy属性的。而是通过使用UIVibrancyEffect初始化,为false的话就是使用UIBlurEffect初始化。
Visual Effect Views with Blur and Vibrancy
直接拖拽它的效果等价于拖拽一个Visual Effect View with Blur,然后在它的contentView上再拖拽一个Visual Effect View with Blur,第二个 Visual Effect View with Blur 设置Blue Style 的Vibrancy的状态为选中状态。
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.light)
let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
let vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect)
let label:UILabel = UILabel()
label.text = "helloworld"
label.font = UIFont.systemFont(ofSize: 80)
label.sizeToFit()
label.textColor = UIColor.red
label.center = CGPoint(x: 100, y: 100)
let label2:UILabel = UILabel()
label2.text = "helloworld 2"
label2.font = UIFont.systemFont(ofSize: 80)
label2.sizeToFit()
label2.textColor = UIColor.red
label2.center = CGPoint(x: 200, y: 200)
blurEffectView.frame = view.bounds
vibrancyEffectView.frame = view.bounds
vibrancyEffectView.contentView.addSubview(label)
blurEffectView.contentView.addSubview(vibrancyEffectView)
blurEffectView.contentView.addSubview(label2)
view.addSubview(blurEffectView)