所以,我有这段代码:
UIView.animate(withDuration: 10.0, delay: 0, options: .curveLinear , animations: {
self.gameLabel.alpha = 0
}, completion: nil)
问题是,当调用此代码时,它立即转到0 alpha并且不会缓慢转换。我做错了什么?
以下是代码的更多上下文:
var gameLabel = SKLabelNode()
override func didMove(to view: SKView) {
gameLabel.fontColor = UIColor.white
gameLabel.fontSize = 85
gameLabel.setScale(0.40)
gameLabel.text = "this is a game"
gameLabel.position = CGPoint(x: 0, y: 0)
gameLabel.zPosition = 0
gameLabel.alpha = 1
addChild(gameLabel)
}
func touchDown(atPoint pos : CGPoint) {
UIView.animate(withDuration: 2, animations: {
self.gameLabel.alpha = 0
})
}
答案 0 :(得分:1)
所以,我通过跑步解决了我的问题。
self.gameLabel.run(SKAction.fadeOut(withDuration: 10))