【发布时间】:2021-05-22 19:16:22
【问题描述】:
我只想在 UIView 周围闪烁红色边框,然后反复淡出以清除。但是,UIView animate 方法似乎不起作用。
阻止 UIView 动画工作的层有什么特别之处吗?
public class MyAlertView: UIView {
convenience init(args: [String]) {
self.init(frame: CGRect.zero)
}
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
private func commonInit() {
self.translatesAutoresizingMaskIntoConstraints = false
self.layer.cornerRadius = 10
self.layer.borderColor = UIColor.systemRed.cgColor
self.layer.borderWidth = 2.5
UIView.animate(withDuration: 0.5, delay: 0.0, options: [.curveEaseInOut, .repeat, .autoreverse], animations: {
self.layer.borderColor = UIColor.clear.cgColor
})
}
}
【问题讨论】:
标签: ios swift animation uiview calayer