我想在一個標簽中顯示多個參考,一次只出現一個參考,并且參考來自服務器端的陣列。我正在這樣做-:
for i in self.splashModel?.quotations ?? [] {
self.quoteLabel.alpha = 0
self.quoteLabel.text = i
self.quoteLabel.fadeIn(completion: {
(finished: Bool) -> Void in
self.quoteLabel.fadeOut()
})
}
此代碼僅顯示陣列的最后一個參考。
uj5u.com熱心網友回復:
你可以試試
self.splashModel?.quotations.enumerated().forEach { (index,item) in
DispatchQueue.main.asyncAfter(deadline: .now() Double( index * 2) ) {
self.quoteLabel.alpha = 0
self.quoteLabel.text = item
self.quoteLabel.fadeIn(completion: {(finished: Bool) -> Void in
self.quoteLabel.fadeOut()
})
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/359291.html
上一篇:應用程式啟動后如何繼續制作影片?
