啥叫高斯模糊
高斯模糊(英语:GaussianBlur),也叫高斯平滑,是在AdobePhotoshop、GIMP以及Paint。NET等图像处理软件中广泛使用的处理效果,通常用它来减少图像噪声以及降低细节层次。俗称毛玻璃效果。
实现代码
class XXXXXTopCell: UICollectionViewCell {
var topBgImageView = UIImageView()
override init(frame: CGRect) {
super.init(frame: frame)
topBgImageView.contentMode = .scaleAspectFill
topBgImageView.clipsToBounds = true
contentView.addSubview(topBgImageView)
topBgImageView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
let blurEffect = UIBlurEffect(style: .systemUltraThinMaterialDark)
let visualEffectView = UIVisualEffectView(effect: blurEffect)
contentView.addSubview(visualEffectView)
visualEffectView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
visualEffectView.layer.masksToBounds = true
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}