以下是您可以使用的發光示例,您需要混合一點顏色和發光,但這是您的開始。我還包括了動畫例如,如果你需要它:
動畫:
func makeViewShine(view: UIView) {
view.layer.shadowColor = UIColor.yellow.cgColor
view.layer.shadowRadius = 10.0
view.layer.shadowOpacity = 1.0
view.layer.shadowOffset = .zero
UIView.animate(withDuration: 0.7, delay: 0, options: [.autoreverse, .curveEaseInOut, .repeat, .allowUserInteraction], animations: {() -> Void in
view.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
}, completion: {(finished: Bool) -> Void in
view.layer.shadowRadius = 0.0
view.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
})
}
沒有動畫:
func makeViewShine(view: UIView) {
view.layer.shadowColor = UIColor.yellow.cgColor
view.layer.shadowRadius = 10.0
view.layer.shadowOpacity = 1.0
view.layer.shadowOffset = .zero
}
要使用它,只需調用方法和通風景。
#Rashwan L,我希望view.layer.shadowRadius = 100.0或200.0或300.0的全屏動畫。當我改變shadowRadius 10到100它不工作:( 但是,謝謝你 – user3833693