对于苹果用户,对于用户毛玻璃效果是很多用户喜欢的一个模式,但是对于开发者可就惨了,我说的是初级开发者,之前我开发毛玻璃,有三种方法,我只提前两者的思路,
方法一:
UIToolBar
方法二:
GPUImage
方法三:
废话少说,少说废话,上代码,简单的跟一似得!注意:下面这个方法是iOS8出来的!
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let img = UIImageView() img.image = UIImage(named:"123.jpg") img.frame = self.view.bounds img.contentMode = .scaleAspectFill view.addSubview(img) let effect = UIBlurEffect.init(style: .light) let effectView = UIVisualEffectView.init(effect: effect) effectView.frame = CGRect(x:0,y:0,width:300,height:300) img.addSubview(effectView) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }如果转载请注明转于: AirZilong的博客