Ophiuchus Custom Label to apply animations on whole text or letters.
  • June 3, 2025

Custom Label to apply animations on whole text or letters.

Yalantis

Check an article on our blog

Inspired by this project on Dribble

Installation


CocoaPods

pod ‘Ophiuchus’, ‘~> 1.0.3’

Manual Installation

Alternatively you can directly add all the source files from Ophiuchus to your project.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Open your project in Xcode, then drag and drop all folders directories in Pods/Classes/ onto your project (use the “Product Navigator view”). Make sure to select Copy items when asked if you extracted the code archive outside of your project.
  3. Include YALLabel wherever you need it with #import "YALLabel.h".

Introduction


YALProgressAnimatingLayer

YALProgressAnimatingLayer is a subclass of CAShapeLayer designed to control animations with progress. This feature is disabled until you invoke [layer allowProgressToControlAnimations], after that duration and timeOffset properties of the layer will be passed to any animation added to the layer. Thus you gain control over animations added to the layer by passing values to progress property (varies from 0.f to 1.f). YALProgressAnimatingLayer mask is of same type as the layer.

YALTextLayer

YALTextLayer is a subclass of YALProgressAnimatingLayer designed to display array of UIBezierPath instances as YALProgressAnimatingLayer sublayers. You can access and manipulate each letter sublayer. YALTextLayer constructs sublayers with mask of

bounding box of shapes they have by default.

YALLabel

YALLabel is a custom label consisting of three YALTextLayer instances to draw background fill, stroke and fill of text.

Usage


Drop a UIView on a storyboard and set it’s class to YALLabel and configure fontNamefontSizetextstrokeWidth and colors.

You can #import "YALLabel.h" in your view controller and create it from code :


self.yalLabel = [[YALLabel alloc] initWithFrame:frame];
self.yalLabel.text = @”AnyText”;
self.yalLabel.fontName = @”FontName”;
self.yalLabel.fontSize = 60.f;
self.yalLabel.fillColor = [UIColor redColor];
self.yalLabel.backgroundFillColor = [UIColor blackColor];
self.yalLabel.strokeColor = [UIColor blackColor];
self.yalLabel.strokeWidth = 1.2f;

After self.yalLabel is drawn you can add any animations to any sublayer you want.

Example: add fill animation to mask as in example but only to first letter: Don’t forget to import YALPathFillAnimation.h.

YALProgressAnimatingLayer *firstLetter = [self.yalLabel.fillLayer.sublayers firstObject];
CABasicAnimation *fillAnimation = [YALPathFillAnimation animationWithPath:fillLayer.mask.path andDirectionAngle:0];
fillAnimation.duration = 3.0;

[firstLetter.mask addAnimation:fillAnimation forKey:@”fillAnimation”];

You can also animate layer with progress:

YALProgressAnimatingLayer *secondLetter = self.yalLabel.fillLayer.sublayers[1];
CABasicAnimation *colorAnimation = [CABasicAnimation animationWithKeyPath:@”fillColor”];

colorAnimation.fromValue = (id)[UIColor redColor].CGColor;
colorAnimation.toValue = (id)[UIColor blueColor].CGColor;

[secondLetter allowProgressToControlAnimations];
[secondLetter addAnimation:colorAnimation forKey:@”colorAnimation”];

secondLetter.progress = 0.f;

And then when you need to update progress:

YALProgressAnimatingLayer *secondLetter = self.yalLabel.fillLayer.sublayers[1];
secondLetter.progress = value;

GitHub


View Github

#animation #cocoapods #ios #objective-c #yalantis
YOU MIGHT ALSO LIKE...
MijickPopups Hero

  Popups Alerts Resizable Sheets Banners

SwiftUI Tooltip

This package provides you with an easy way to show tooltips over any SwiftUI view, since Apple does not provide ...

SimpleToast for SwiftUI

SimpleToast is a simple, lightweight, flexible and easy to use library to show toasts / popup notifications inside iOS or ...

SSToastMessage

Create Toast Views with Minimal Effort in SwiftUI Using SSToastMessage. SSToastMessage enables you to effortlessly add toast notifications, alerts, and ...

ToastUI

A simple way to show toast in SwiftUI   Getting Started • Documentation • Change Log