0
我想创建一个自定义UIView类,我可以更改我的应用程序中的一些视图的类。我希望视图变成圆形并具有模糊效果。我可以通过func工作,它专门引用了插座名称,但是只想改变视图的类,使其可重复使用。自定义UIView类与模糊
import UIKit
class RoundedBlur: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
self.addRoundedBlur()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.addRoundedBlur()
}
func addRoundedBlur() {
let roundedBlurView = UIView()
let blur = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.light))
blur.frame = roundedBlurView.bounds
blur.layer.cornerRadius = 0.5 * roundedBlurView.bounds.size.width
blur.clipsToBounds = true
blur.autoresizingMask = [.flexibleWidth, .flexibleHeight]
roundedBlurView.insertSubview(blur, at: 0)
}
}
那么......问题是什么? – dfd
那么...什么是UIVisualEffectView? –