Product Promotion
0x5a.live
for different kinds of informations and explorations.
GitHub - lexrus/LTMorphingLabel: [EXPERIMENTAL] Graceful morphing effects for UILabel written in Swift.
[EXPERIMENTAL] Graceful morphing effects for UILabel written in Swift. - lexrus/LTMorphingLabel
Visit SiteGitHub - lexrus/LTMorphingLabel: [EXPERIMENTAL] Graceful morphing effects for UILabel written in Swift.
[EXPERIMENTAL] Graceful morphing effects for UILabel written in Swift. - lexrus/LTMorphingLabel
Powered by 0x5a.live 💗
LTMorphingLabel
A morphing UILabel subclass written in Swift, originally designed to mimic Apple's QuickType animation in iOS 8 at WWDC 2014.
Table of Contents
- Available Effects
- Usage
- Requirements
- Installation
- Unit Testing
- Apps Using
LTMorphingLabel
- Third-Party Ports
- License
Available Effects
.scale (default)
.evaporate
.fall
.pixelate
.sparkle
.sparkle
is built on top ofQuartzCore.CAEmitterLayer
. There is also a SpriteKit-powered version here.
.burn
.anvil
Usage
UIKit
Since LTMorphingLabel
is a drop-in replacement, you can use it like any UILabel
by setting its text property, yielding the default effect (.scale
):
var exampleLabel = LTMorphingLabel()
exampleLabel.text = "This is a test"
Alternatively, it can be used interactively:
var exampleLabel = LTMorphingLabel()
exampleLabel.text = "This is a test"
exampleLabel.pause()
// Call .updateProgress(progress: Float) for interactive animation
// Note: In this case, animation will stop at 45% and will not complete
// unless called later with 100 as the `progress` float value.
exampleLabel.updateProgress(progress: 45.0)
The effect can be changed by setting the morphingEffect
property:
var exampleLabel = LTMorphingLabel()
exampleLabel.text = "This is a test"
exampleLabel.morphingEffect = .burn
SwiftUI
To use LTMorphingLabel
in SwiftUI, simply declare it and set its text, effect
, font
, and textColor
properties:
public var body: some View {
VStack {
MorphingText(
"This is a test",
font: UIFont.systemFont(ofSize: 20),
textColor: .black,
textAlignment: .center
)
.frame(maxWidth: 200, maxHeight: 100)
}
}
Similar to its use in UIKit, you can also specify the morphing effect manually (if you do not want to use the default .scale
effect):
public var body: some View {
VStack {
MorphingText(
"This is a test",
effect: .burn, // Specify an alternative morphing effect with this line
font: UIFont.systemFont(ofSize: 20),
textColor: .black,
textAlignment: .center
)
.frame(maxWidth: 200, maxHeight: 100)
}
}
Requirements
- Xcode 12+
- iOS 9.0+ (note that SwiftUI requires iOS 13+)
Installation
Swift Package Manager
Simply add this library to your package manifest or follow instructions on adding a package dependency using Xcode here.
.package(
url: "https://github.com/lexrus/LTMorphingLabel.git",
.branch("master")
)
CocoaPods
Add pod 'LTMorphingLabel'
to your Podfile or follow instructions to add dependencies here.
Carthage
Add github "lexrus/LTMorphingLabel"
to your Cartfile or follow instructions on adding frameworks here.
XCFramework
A pre-compiled xcframework
file is available on the Releases page.
Accio
-
Add this library to your package manifest (see Swift Package Manager)
-
Update your target dependencies to include
LTMorphingLabel
:
.target(
name: "App",
dependencies: [
"LTMorphingLabel",
]
),
- Run
accio update
.
Unit Testing
Clone the repo by running git clone https://github.com/lexrus/LTMorphingLabel.git
, then open the project with Xcode and press Cmd + U (or, in the menu bar, click Product > Build for > Testing).
Apps Using LTMorphingLabel
- Idea by Igor Matyushkin
- Speedo[kilo]meter by Alberto Pasca
- Vatomium by Erik Telepovský
- Atmos by @shnhrrsn
- The Met Challenge by @lazerwalker
- Uther by @callmewhy
- Reax by Reax Inc
- Puzzpic by Moath Othman
- Drops by Mark Aron Szulyovszky
- Setgraph Workout Log by Arturo Lee
- Nihon by KyXu
- Lightsync by Marcel Braun
- Find by A. Zheng
Third-Party Ports
Android
The Android port of this library is available here.
React Native
The React Native port of this library is available here.
License
This code is distributed under the terms and conditions of the MIT license.
Swift Resources
are all listed below.
Made with ❤️
to provide different kinds of informations and resources.