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? –