可以使用UIVIEw.animate实现吗?
下面给出了一个粗略的想法. 解决方法 真的很喜欢这个灵感.还有两种方法可以将其添加到您的应用中:
1)这是我为您的实例创建的代码:
导入UIKit
class VIEwController: UIVIEwController { let listofRandomLetters = ["@","%","*","^","1","2","3"," "," "] var textNeeddisplaying = ["String","Other Person","Sample","String","Sample"] var newList: [String] = [] var incrementer = 0 var internalTimer: Timer? var timer: Timer? var mainTimer: Timer? @IBOutlet weak var animatingLabel: UILabel! overrIDe func vIEwDIDAppear(_ animated: Bool) { schedule() } func schedule() { //Main Timer interval usually adds up the other two intervals self.mainTimer = Timer.scheduledTimer(withTimeInterval: 1,repeats: true,block: { _ in //Play around with the time Intervals self.internalTimer = Timer.scheduledTimer(withTimeInterval: 0.1,block: { _ in for _ in 0...arc4random_uniform(UInt32(10)) + 1 { let randomNumber = arc4random_uniform(UInt32(self.listofRandomLetters.count - 1)) self.newList.append(self.listofRandomLetters[Int(randomNumber)]) } self.animatingLabel.text = self.newList.joined() self.newList.removeAll() }) //Play around with the time Intervals self.timer = Timer.scheduledTimer(withTimeInterval: 0.7,repeats: false,block: { _ in if self.incrementer != self.textNeeddisplaying.count - 1 { self.internalTimer?.invalIDate() self.animatingLabel.text = self.textNeeddisplaying[self.incrementer] self.incrementer += 1 } else { self.timer?.invalIDate() self.internalTimer?.invalIDate() self.mainTimer?.invalIDate() self.animatingLabel.text = "DONE" } }) }) }}
如果你想让各个字母都有动画让我知道.我会做到这一点……确保标签的宽度约束足够大以适应你的话.此外,如果代码可以更简洁或更好,请告诉我.
2)使用LottIE和After Effects进行更加个性化的过渡.如果您对此感兴趣,请告诉我:链接:https://airbnb.design/lottie/.
总结以上是内存溢出为你收集整理的ios – 如何在Swift的位置上制作扰乱字母的动画?全部内容,希望文章能够帮你解决ios – 如何在Swift的位置上制作扰乱字母的动画?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)