LTMorphingLabel 0.9.3

LTMorphingLabel 0.9.3

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布上次发布2021年1月
SPM支持 SPM

Lex Tang 维护。




LTMorphingLabel

Travis Language CocoaPods Carthage compatible Accio supported License

Swift 编写的可以变形的 UILabel 子类。模仿了 WWDC 2014 上苹果的 QuickType 动画效果,如 iOS 8。新的变形效果可以通过 Swift 扩展获得。

枚举 LTMorphingEffect: Int, Printable

.Scale - 默认

LTMorphingLabel

.Evaporate

LTMorphingLabel-Evaporate

.Fall

LTMorphingLabel-Fall

.Pixelate

LTMorphingLabel-Pixelate

.Sparkle

LTMorphingLabel-Sparkle

.Sparkle 是基于 QuartzCore.CAEmitterLayer 构建的。这里还有一个由 SpriteKit 驱动的版本

.Burn

LTMorphingLabel-Burn

.Anvil

LTMorphingLabel-Anvil

SwiftUI

LTMorphingLabelSwiftUI

public var body: some View {
    VStack {
        MorphingText(
            "Awesome Morphing Text",
            effect: .evaporate,
            font: UIFont.systemFont(ofSize: 20),
            textColor: .black,
            textAlignment: .center
        ).frame(maxWidth: 200, maxHeight: 100)
        ...

需求

  1. iOS 12
  2. iOS 9.0+

安装

Swift Package Manager

  1. 文件 > Swift 包 > 添加包依赖
  2. 复制并粘贴 https://github.com/lexrus/LTMorphingLabel 然后按照说明操作

XCFramework

XCFramework 是 Xcode 11 中引入的新选项。您可以手动从 发行版页面 下载预编译的 LTMorphingLabel.xcframework.zip,然后将其拖放到项目中。

Carthage

  1. 将此行添加到 Cartfile: github "lexrus/LTMorphingLabel"
  2. 阅读 官方说明

CocoaPods

  1. 安装 CocoaPods 的最新版本: gem install cocoapods
  2. 将此行添加到 Podfile: pod 'LTMorphingLabel'
  3. 安装 Pod: pod install

Accio

  1. 将以下内容添加到您的 Package.swift 文件中
.package(url: "https://github.com/lexrus/LTMorphingLabel.git", .upToNextMajor(from: "0.9.2")),
  1. 接下来,将 LTMorphingLabel 添加到您的应用的依赖中,如下所示:
.target(
    name: "App",
    dependencies: [
        "LTMorphingLabel",
    ]
),
  1. 然后运行 accio update

用法

  1. 将标签的类从 UILabel 改为 LTMorphingLabel;
  2. 以编程方式将其文本属性设置为新的字符串。
  3. 要交互使用,在更改 .text 属性后调用 .pause(),并使用 updateProgress(progress: Float) 来交互式地更新进度。

单元测试

在 Xcode 中打开项目,然后按 command + u。

其他选项

尽管这个库被用于 App Store 中的几个产品,它仍然是一个实验性项目。坦白说,这里还有一些很好的竞争者既能保证兼容性也能保证稳定性。其中最突出的是 ZCAnimatedLabel。我建议对其进行生产使用。

最后,还有一个 Android 端版本

第三方绑定

React Native

现在您可以通过React Native中的模块这里使用这个库。

许可证

本代码在MIT许可证的条款和条件下分发。