我試圖在屏幕上出現淡入淡出的標籤。目前,我只是隱藏它使用(Swift)淡入淡出標籤
button.hidden = true
並通過使用false取消隱藏它。我想用淡入淡出的方式來製作這個過程,因爲這樣看起來更平滑。感謝幫助!
以下是我使用的代碼出錯。 http://imgur.com/a/HI4eg
class ViewController: UIViewController {
@IBOutlet weak var yeah: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
UIView.animateWithDuration(1.0, delay: 0.0, options: .CurveEaseOut, animations: {
self.yeah.alpha = 0.0
}, completion: {
(finished: Bool) -> Void in
//Once the label is completely invisible, set the text and fade it back in
self.yeah.text = "your Text "
// Fade in
UIView.animateWithDuration(1.0, delay: 0.0, options: .CurveEaseIn, animations: {
self.yeah.alpha = 1.0
}, completion: {
(finished: Bool) -> Void in
//Once the label is completely invisible, set the text and fade it back in
self.yeah.text = "your Text "
// Fade in
UIView.animateWithDuration(1.0, delay: 0.0, options: .CurveEaseIn, animations: {
self.yeah.alpha = 1.0
}, completion:nil)
})
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
} }
您是否正在尋找與淡出一躲,並與褪色顯示有效?由於默認隱藏不具動畫性? – Shripada