使用“ @IBOutlet var checkAvalibilityBtn:UIButton!”,创建一个闪烁的代码,并在viewdidLoad中调用
`override func viewDidLoad() {
super.viewDidLoad()
self.checkAvalibilityBtn.alpha = 1.0
UIView.animate(withDuration: 0.80, delay: 0.0, options: [.curveEaseIn, .repeat, .autoreverse, .allowUserInteraction], animations: {() -> Void in
self.checkAvalibilityBtn.alpha = 0.0
}, completion: {(finished: Bool) -> Void in
})`
但是对接操作不起作用
@IBAction func checkBAvaBtnClick(_ sender: UIButton) {
print("Success")
}
答案 0 :(得分:2)
view alpha 0不能从系统接收触摸事件,请参考旧的answer
override func viewDidLoad() {
super.viewDidLoad()
self.checkAvalibilityBtn.alpha = 0.0
UIView.animate(withDuration: 0.80, delay: 0.0, options: [.curveEaseIn, .repeat, .autoreverse, .allowUserInteraction], animations: {() -> Void in
self.checkAvalibilityBtn.alpha = 1.0
}, completion: {(finished: Bool) -> Void in
})