I want to show multiple quotation in one label and at a time only one quotation appear and quotation is coming from server side in array. I am doing this -:
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()
})
}
this code show only last quotation of array.
CodePudding user response:
You can try
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()
})
}
}