毛玻璃效果
先上效果图:
let mWidth = UIScreen.main.bounds.width
let mHieght = UIScreen.main.bounds.height
override func viewDidLoad() {
super.viewDidLoad()
//模糊效果
let lBlurEffect = UIBlurEffect(style: .light)
let lVisualEffectView = UIVisualEffectView(effect: lBlurEffect)
lVisualEffectView.frame = CGRect(x: 10, y: 100, width: mWidth - 20, height: (mWidth - 20) * 3 / 4)
let lImageView = UIImageView()
lImageView.frame = lVisualEffectView.frame
lImageView.image = UIImage(named: "77.jpeg")
self.view.addSubview(lImageView)
self.view.addSubview(lVisualEffectView)
let lSmallImageView = UIImageView()
lSmallImageView.frame = CGRect(x: 0, y: 0, width: mWidth - 100, height: (mWidth - 100) * 3 / 4)
lSmallImageView.center = lImageView.center
lSmallImageView.image = UIImage(named: "77.jpeg")
self.view.addSubview(lSmallImageView)