LTMorphingLabel
  • November 24, 2023

A morphing UILabel subclass written in Swift. The .Scale effect mimicked Apple’s QuickType animation of iOS 8 of WWDC 2014. New morphing effects are available as Swift extensions.

enum LTMorphingEffect: Int, Printable


.Scale – default

.Evaporate

.Fall

.Pixelate

.Sparkle

.Sparkle is built on top of QuartzCore.CAEmitterLayer. There’s also a SpriteKit powered version here.

 

.Burn

.Anvil

 

SwiftUI


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)

Requirements


  1. Xcode 12
  2. iOS 9.0+

Installation


Swift Package Manager

  1. File > Swift Packages > Add Package Dependency
  2. Copy & paste https://github.com/lexrus/LTMorphingLabel then follow the instruction

XCFramework

XCFramework is a new option introduced in Xcode 11. You can manually download the pre-compiled LTMorphingLabel.xcframework.zip from the Releases page. Then drag and drop it into your project.

Carthage

  1. Add this line to your Cartfile: github "lexrus/LTMorphingLabel"
  2. Read the official instruction

CocoaPods

  1. Install the latest release of CocoaPods: gem install cocoapods
  2. Add this line to your Podfile: pod 'LTMorphingLabel'
  3. Install the pod: pod install

Accio

  1. Add the following to your Package.swift:

.package(url: “https://github.com/lexrus/LTMorphingLabel.git”, .upToNextMajor(from: “0.9.2”)),

  1. Next, add LTMorphingLabel to your App targets dependencies like so:

.target(
name: “App”,
dependencies: [
“LTMorphingLabel”,
]
),

  1. Then run accio update.

Usage


  1. Change the class of a label from UILabel to LTMorphingLabel;
  2. Programmatically set a new String to its text property.
  3. To use interactively, call .pause() after changing .text property, and use updateProgress(progress: Float)to update the progress interactively.

Unit tests


Open the project with Xcode then press command + u.

Alternative


Even though this lib was used in a few products on App Store, it’s still an experimental project. Frankly, there’re some nice competitors out there guarantee both compatibility and stability. And the most outstanding one is ZCAnimatedLabel. I’d like to recommend it for production use.

And finally, an Android port.

GitHub


View Github

#effects #framework #ios #ltmorphinglabel #swift #uilabel #xcode
YOU MIGHT ALSO LIKE...
CameraBackground

Features Both front and back camera supported. Flash modes: auto, on, off. Countdown timer. Tap to focus. Pinch to zoom. Usage  

DKCamera

Description A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so ...

HorizonSDK-iOS

Horizon SDK is a state of the art real-time video recording / photo shooting iOS library. Some of the features ...

LLSimpleCamera

LLSimpleCamera: A simple customizable camera - video recorder control LLSimpleCamera is a library for creating a customized camera - video ...

RSBarcodes_Swift

RSBarcodes allows you to read 1D and 2D barcodes using the metadata scanning capabilities introduced with iOS 7 and generate ...