gpt4 book ai didi

ios - 如何在swift 3中实现ZCAnimatedLabel的默认效果

转载 作者:行者123 更新时间:2023-11-30 12:15:02 25 4
gpt4 key购买 nike

我正在尝试为标签制作动画。我想要像下面这样的动画。

enter image description here

objective-C 中的 ZCAnimatedLabel 库 ( https://github.com/overboming/ZCAnimatedLabel ) 我使用 pod 将此库集成到我的项目中。但我不知道如何实现这个动画。

编辑

现在,我删除我的 Pod 并创建一个桥接 header ,并将 UIView 放入 Storyboard 中,并将 ZCAnimatedLabel 作为其类

enter image description here

我应该在ViewController.swift中写什么才能在ViewDidLoad中实现这种效果

最佳答案

我通过pod'ZCAnimatedLabel'并在桥接 header 文件中添加#import“ZCAnimatedLabel.h”

UIView 拖放到场景/xib 中并按照您想要的方式布局。

import ZCAnimatedLabel 

在您的 UIViewController 中,添加 IBOutlet 并在 scene/xib 中将您的 UIView 类 更改为您想要的动画标签类型。对于default行为,将其更改为ZCAnimatedLabelclass并添加以下代码进行动画处理。

self.label.animationDuration = 1 // add animation duration
self.label.animationDelay = 1 // add seconds to delay
self.label.text = "some text"
self.label.startAppearAnimation()

并停止动画

self.label.stopAnimation()

我在 viewWillAppear 中开始动画,并在 viewWillDisappear 中停止。

重要说明:我在 swift 5 中做到了这一点

关于ios - 如何在swift 3中实现ZCAnimatedLabel的默认效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45532066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com