Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edudnyk/labelkit
A UILabel that does true animation of attributed text.
https://github.com/edudnyk/labelkit
animation catextlayer library swift uilabel
Last synced: about 1 month ago
JSON representation
A UILabel that does true animation of attributed text.
- Host: GitHub
- URL: https://github.com/edudnyk/labelkit
- Owner: edudnyk
- License: other
- Created: 2019-06-19T22:30:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-10-10T10:59:00.000Z (about 3 years ago)
- Last Synced: 2024-10-01T16:49:51.560Z (about 2 months ago)
- Topics: animation, catextlayer, library, swift, uilabel
- Language: Swift
- Homepage:
- Size: 125 KB
- Stars: 15
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ![LabelKit](https://media.githubusercontent.com/media/edudnyk/LabelKit/master/LabelKit.gif)
[![build status](https://travis-ci.org/edudnyk/LabelKit.svg)](https://travis-ci.org/edudnyk/LabelKit)
[![cocoapods compatible](https://img.shields.io/badge/cocoapods-compatible-brightgreen.svg)](https://cocoapods.org/pods/LabelKit)
[![carthage compatible](https://img.shields.io/badge/carthage-compatible-brightgreen.svg)](https://github.com/Carthage/Carthage)
[![language](https://img.shields.io/badge/spm-compatible-brightgreen.svg)](https://swift.org)
[![swift](https://img.shields.io/badge/swift-5.3-green.svg)](https://github.com/edudnyk/LabelKit/releases)A `UILabel` that does true animation of attributed text.
It animates all text attributes that are possible to animate, unlike `CATextLayer` that animates only font and color.
It also has a great support of multiline text animations while keeping almost all the benefits of being `UILabel`.
It uses CoreText text rendering instead of CoreGraphics text rendering of `CATextLayer`. That makes the text to look the same by advancement and line height as the text in regular `UILabel`.
It is a great and simple building block for UI which implements material design.
## Features
- [x] [Documentation](https://edudnyk.github.io/LabelKit/index.html)
- [x] Unit Test Coverage## Requirements
![xcode](https://img.shields.io/badge/xcode-12%2b-lightgrey.svg)
![ios](https://img.shields.io/badge/ios-12.0%2b-lightgrey.svg)
![tvos](https://img.shields.io/badge/tvos-12.0%2b-lightgrey.svg)
![mac os](https://img.shields.io/badge/mac%20os-10.15%2b-lightgrey.svg)Installation >> [`instructions`](https://github.com/edudnyk/LabelKit/blob/master/INSTALL.md) <<
## Usage
You can use either `LKLabel` or `LKLabelLayer`, both support implicitly animatable text change.
When the layer is hosted by `LKLabel`, animations of text during bounds change are more stable.Animating text change in `LKLabel` can be something like this:
```swift
// Swift
self.label.superview.setNeedsLayout()
self.label.setNeedsLayout()
UIView.animate(withDuration: 3, delay: 0, options: [], animations: {
self.label.attributedText = attributedText
self.label.superview.layoutIfNeeded()
}, completion: nil)
``````objective-c
// Objective-C
[self.label.superview setNeedsLayout];
[self.label setNeedsLayout];
[UIView animateWithDuration:3 delay:0 options:kNilOptions animations:^{
self.label.attributedText = attributedText;
[self.label.superview layoutIfNeeded];
} completion:nil];
```Animating text change in `LKLabelLayer` can be something like this:
```swift
// Swift
CATransaction.begin()
CATransaction.setAnimationDuration(3.0)
labelLayer.attributedText = attributedText
CATransaction.commit()
``````objective-c
// Objective-C
[CATransaction begin];
[CATransaction setAnimationDuration:3.0];
labelLayer.attributedText = attributedText;
[CATransaction commit];
```> Refer to the [`documentation`](https://edudnyk.github.io/LabelKit/index.html) for the detailed description of possibilities.
## License
LabelKit is released under the Simplified BSD license. See [LICENSE](https://github.com/edudnyk/LabelKit/blob/master/LICENSE) for details.