【发布时间】:2017-11-22 19:05:15
【问题描述】:
我有一个游戏,对于主页,我希望“点击播放”按钮淡入淡出。这是我的代码:
import UIKit
class HomePageViewController: UIViewController {
@IBOutlet weak var highscoreLabel: UILabel!
@IBOutlet weak var taptoplay: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
flashing(buttonName: taptoplay)
let highscore = UserDefaults.standard.integer(forKey: "highscore")
highscoreLabel.text = "Highscore: \(highscore)"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func flashing(buttonName:UIButton) {
UIView.animate(withDuration: 1, delay: 0, options: UIViewAnimationOptions.autoreverse, animations: {
buttonName.alpha = 1
buttonName.alpha = 0
}, completion: nil)
}
}
我的问题是文本完全按照我想要的方式闪烁了大约两次,但随后它就消失了,我什至无法单击按钮。事实上,即使它正确闪烁,我也无法单击该按钮。
在我添加此代码之前,该按钮工作正常,并且所有链接仍然正确。感谢您的帮助。
【问题讨论】: