-1
我想制作一个动画,如图中所示。在我给出的示例代码中,点击后的字符被覆盖。我怎样才能制作一幅如图所示的动画。UILabel动画文字
谢谢。
func letterTapAction(sender: UITapGestureRecognizer) {
for label in lettesLabel {
if sender.view == label {
copyLabelAndAnimate(fromLabel: label)
}
}
}
func copyLabelAndAnimate(fromLabel: UILabel) {
let copiedLabel = UILabel.init(frame: CGRect(x: fromLabel.frame.minX, y: fromLabel.frame.minY ,width: fromLabel.bounds.width, height: fromLabel.bounds.height))
copiedLabel.text = fromLabel.text!
copiedLabelsTagCounter += 1
copiedLabel.tag = copiedLabelsTagCounter
copiedLabel.font = UIFont.init(name: "Noteworthy-Bold", size: 28.0)
view.addSubview(copiedLabel)
//UIView.removeFromSuperview(view.viewWithTag(101)!)
UIView.animate(withDuration: 0.2, animations: {
copiedLabel.frame.origin = CGPoint.init(x: self.view.frame.size.width/2 + CGFloat(self.spaceForCopiedLabels), y: self.view.frame.minY + CGFloat(15))
})
if lettersThatNeedLessSpace.characters.contains(copiedLabel.text!.characters.first!) {
spaceForCopiedLabels -= 8
}
spaceForCopiedLabels += 25
}
您昨天已经问同样的问题。 –
是的,我昨天写了。评论和答案是写在。但我无法解决这个问题。我知道这是违规,但我必须。 –